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



Download 7,31 Mb.
Pdf ko'rish
bet11/89
Sana21.04.2022
Hajmi7,31 Mb.
#571320
1   ...   7   8   9   10   11   12   13   14   ...   89
Bog'liq
Grokking-The-Java-Developer-Interview-More-Than-200-Questions-To-Crack-The-Java -Spring -SpringBoot-

chain by default ,


You have to use throws keyword if you want to propagate the
checked exception, like
Notice in the above example that the checked exception is
propagated and now it is the responsibility of the caller method to
either handle the exception or throw it further. Below example is
showing that the checked exception is handled ,
Output:


throws can be used with unchecked exceptions also, though it is of
no use because unchecked exceptions are by default propagated.
See this in the below program:
Output:
Unchecked exceptions are by default propagated:


Output:
Question 22: Exception handling w.r.t. method
overriding
Answer:
If the parent class method does not declare an exception
then child class overridden method cannot declare
checked exceptions but it can declare unchecked
exceptions
If the parent class method declares an exception, then
child class overridden method
- can declare no exception
- can declare same exception
- can declare a narrower exception (more broader
exception declaration than parent one is not allowed)
Example when parent class method does not declare an
exception and child class declares checked exception :


Example when parent class method does not declare an
exception and child class declares unchecked exception :


Output:
Example when Child class overridden method throws a broader

Download 7,31 Mb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   ...   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