Grokking The Java Developer Interview: More Than 200 Questions To Crack The Java, Spring, SpringBoot & Hibernate Interview


When no-arg constructor is present in Super class



Download 7,31 Mb.
Pdf ko'rish
bet38/89
Sana21.04.2022
Hajmi7,31 Mb.
#571320
1   ...   34   35   36   37   38   39   40   41   ...   89
Bog'liq
Grokking-The-Java-Developer-Interview-More-Than-200-Questions-To-Crack-The-Java -Spring -SpringBoot-

When no-arg constructor is present in Super class:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
58\Case 2\without error\color1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
58\Case 2\without error\color2.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
58\Case 2\without error\color3.png


(Note: serializeObject() and deserializeObject() remains same as the
Case 1 program)
Output:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
58\Case 2\without error\output.png


Question 59: Stopping Serialization and De-
serialization
Suppose, parent class implements Serializable interface but we don’t
need the child class to be serialized
Here, we can implement writeObject() and readObject() methods in
sub-class and throw NotSerializableException from these methods :


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
59\color1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
59\color2.png


(Note: serializeObject() and deserializeObject() remains same as the
Question 58 - Case 1 program)
Output:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
59\error1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
59\error2.png


Serialization and De-serialization process can be customized also by
providing writeObject() and readObject() methods in the class that
we want to serialize.


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
58\CustomLogic.png


Declaring both methods as private is necessary (public methods will
not work), so other than the JVM nothing else can see them. This
also proves that neither method is not inherited nor overridden or
overloaded. The JVM automatically checks these methods and calls
them during the serialization-deserialization process. The JVM can
call these private methods, but other objects cannot. Thus, the
integrity of the class is maintained and the serialization protocol can
continue to work as normal.
For example, you can have encryption and decryption logic in these
methods.

Download 7,31 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   89




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish