Can you please explain why answer is A and not D ??
10. What is the result when you compile the and run the following code?
public class ThrowsDemo {
static void throwMethod() {
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
public static void main(
String args[]) {
try {
throwMethod();
} catch (IllegalAccessException e) {
System.out.println("Caught " + e);
}
}
}
A) Compilation error
B) Runtime error
C) Compile successfully, nothing is printed.
D) Inside throwMethod. followed by caught: java.lang.IllegalAccessExcption: demo
Answer 10:
A) Compilation error
-------------
Can you please explain why answer is C and not A or B?
20. What is the output of the following code?
public class TestLocal {
public static void main(String args[]) {
String s[] = new String[6];
System.out.print(s[6]);
}
}
A) A null is printed
B) Compile time error
C) Exception is thrown
D) null followed by 0 is printed on the screen
Answer 20: C) Exception is thrown
thanx
[ September 17, 2002: Message edited by: Richa Jeetah ]