Java Interview Guide: How to Build Confidence With a Solid Understanding of Core Java Principles pdfdrive com



Download 0,53 Mb.
Pdf ko'rish
bet13/47
Sana12.07.2022
Hajmi0,53 Mb.
#783570
1   ...   9   10   11   12   13   14   15   16   ...   47
Bog'liq
11-Java Interview Guide

Try/Catch/Finally
Java provides three keywords that are used to establish an error-handling policy.
The 
try
keyword delineates a block of code that might throw an exception.
The 
catch
keyword designates a handler for a specific type of exception.
An exception that is thrown within a 
try
block will be caught by the first
catch
block whose exception type either matches the thrown exception or is
a superclass of the thrown exception.
The 
finally
keyword delineates a block of code that will be invoked
regardless of whether or not an exception was thrown. A 
finally
block
is generally used to provide cleanup operations. For example, code that attempts
to update a database might be surrounded with a 
finally
block because the
database connection should be closed regardless of whether or not the update
was successful.


Try-With-Resources
Java 7 introduced the 
try-with-resources
statement, which allowed resources that
implement the 
AutoCloseable
interface to be declared as parameters inside
of the 
try
block. When the 
try
block completes, the JVM will automatically
call the 
close()
method on those resources, eliminating the need for

finally
block.


Questions
What is an exception?
What is the difference between an unchecked and a checked exception?
How would you determine whether to use an unchecked or a checked exception?
How does a try/catch/finally block work?
How does the try-with-resources statement work?


Generics

Download 0,53 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   ...   47




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