Home Tutorial Java Scjp Part6 SCJP Module-6 Question-6

 
 

Share on Google+Share on Google+
SCJP Module-6 Question-6
Posted on: July 14, 2010 at 12:00 AM
Advertisement
The program given below will test your understanding about the try block catch block and finally block and order of using them in a program.

Given below the sample code :

public class section66 {
public static void main(String[] args) {
try {
System.out.println("Inside try");
} finally {
System.out.println("Inside finally ");
}
System.out.println("at end of the code");
}
}

Find the error in the above code :

1.try block without 'catch'.

2.No errors. Prints :   Inside try
                                 Inside finally
                                 at end of the code

3. Can't use try block inside main.

4.  Finally must be after 'catch'.

Answer :

(2)

Explanation :

Can use 'try' block without 'catch' And also finally without 'catch'.

Advertisement

Related Tags for SCJP Module-6 Question-6:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 14, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com