— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet325/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   321   322   323   324   325   326   327   328   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

348
 
chapter 11
C
True or False
D
Exercise
This chapter explored the wonderful world of 
exceptions. Your job is to decide whether each of the 
following exception-related statements is true or false.
1. A try block must be followed by a catch and a finally block.
2. If you write a method that might cause a compiler-checked exception, you 
must wrap that risky code in a try / catch block.
3. Catch blocks can be polymorphic.
4. Only ‘compiler checked’ exceptions can be caught.
5. If you define a try / catch block, a matching finally block is optional.
6. If you define a try block, you can pair it with a matching catch or finally block, 
or both.
7. If you write a method that declares that it can throw a compiler-checked ex-
ception, you must also wrap the exception throwing code in a try / catch block.
8. The main( ) method in your program must handle all unhandled exceptions 
thrown to it.
9. A single try block can have many different catch blocks.
10. A method can only throw one kind of exception.
11. A finally block will run regardless of whether an exception is thrown.
12. A finally block can exist without a try block.
13. A try block can exist by itself, without a catch block or a finally block.
14. Handling an exception is sometimes referred to as ‘ducking’.
15. The order of catch blocks never matters.
16. A method with a try block and a finally block, can optionally declare the 
exception.
17. Runtime exceptions must be handled or declared.
exercise: 
True or False


you are here
4
exception 
handling
349
A working Java program is scrambled up on the fridge. Can you 
reconstruct all the code snippets to make a working Java program 
that produces the output listed below? Some of the curly braces fell 
on the floor and they were too small to pick up, so feel free to add as 
many of those as you need!
try {
public static void main(String [] args) {
String test = args[0];
System.out.print(“o“);
class MyEx extends Exception { }
public class ExTestDrive {
File Edit Window Help ThrowUp

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   321   322   323   324   325   326   327   328   ...   555




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