class A {
public static void main (String[] args) {
Error error = new Error();
Exception exception = new Exception();
System.out.print((exception instanceof Throwable) + ",");
System.out.print(error instanceof Throwable);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false |
| b. | Prints: false,true |
| c. | Prints: true,false |
| d. | Prints: true,true |
| e. | Compile-time error |
| f. | Run-time error |
| g. | None of the above |
class A {A() throws Exception {}} // 1
class B extends A {B() throws Exception {}} // 2
class C extends A {C() {}} // 3
Which of the following statements are true?
| a. | class A extends Object. |
| b. | Compile-time error at 1. |
| c. | Compile-time error at 2. |
| d. | Compile-time error at 3. |
class A {
public static void main (String[] args) {
Object error = new Error();
Object runtimeException = new RuntimeException();
System.out.print((error instanceof Exception) + ",");
System.out.print(runtimeException instanceof Exception);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false |
| b. | Prints: false,true |
| c. | Prints: true,false |
| d. | Prints: true,true |
| e. | Compile-time error |
| f. | Run-time error |
| g. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 1;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,1,0,0 |
| b. | Prints: 0,0,1,1,0,1 |
| c. | Prints: 0,1,1,1,0,1 |
| d. | Prints: 1,0,1,1,0,1 |
| e. | Prints: 1,1,1,1,0,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 2;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,1,0,0,1 |
| b. | Prints: 0,1,0,0,0,0 |
| c. | Prints: 0,1,1,0,0,1 |
| d. | Prints: 0,1,0,0,0,1 |
| e. | Prints: 1,1,1,0,0,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 3;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1,1,1,0,0,1 |
| b. | Prints: 0,1,1,0,0,1 |
| c. | Prints: 0,1,0,0,0,0 |
| d. | Prints: 0,1,0,0,0,1 |
| e. | Prints: 0,0,1,0,0,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 4;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
case 4: throw new Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally{c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,0,0,1 |
| b. | Prints: 0,0,0,0,1,0 |
| c. | Prints: 0,0,1,0,0,1 |
| d. | Prints: 0,0,1,0,1,1 |
| e. | Prints: 0,1,1,1,1,1 |
| f. | Prints: 1,1,1,1,1,1 |
| g. | Compile-time error |
| h. | Run-time error |
| i. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 5;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
case 4: throw new Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1,0,0,0,0,0 |
| b. | Prints: 1,0,1,0,0,1 |
| c. | Prints: 0,0,1,0,0,1 |
| d. | Prints: 1,1,1,1,1,1 |
| e. | Compile-time error |
| f. | Run-time error |
| g. | None of the above |
class ColorException extends Exception {}
class WhiteException extends ColorException {}
class White {
void m1() throws ColorException {throw new WhiteException();}
void m2() throws WhiteException {}
public static void main (String[] args) {
White white = new White();
int a,b,d,f; a = b = d = f = 0;
try {white.m1(); a++;} catch (ColorException e) {b++;}
try {white.m2(); d++;} catch (WhiteException e) {f++;}
System.out.print(a+","+b+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,1,0,0 |
| b. | Prints: 1,1,0,0 |
| c. | Prints: 0,1,1,0 |
| d. | Prints: 1,1,1,0 |
| e. | Prints: 1,1,1,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class ColorException extends Exception {}
class WhiteException extends ColorException {}
class White {
void m1() throws ColorException {throw new ColorException();}
void m2() throws WhiteException {throw new ColorException();}
public static void main (String[] args) {
White white = new White();
int a,b,d,f; a = b = d = f = 0;
try {white.m1(); a++;} catch (ColorException e) {b++;}
try {white.m2(); d++;} catch (WhiteException e) {f++;}
System.out.print(a+","+b+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,1,0,0 |
| b. | Prints: 1,1,0,1 |
| c. | Prints: 0,1,0,1 |
| d. | Prints: 0,1,1,1 |
| e. | Prints: 1,1,1,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class ColorException extends Exception {}
class WhiteException extends ColorException {}
class White {
void m1() throws ColorException {throw new ColorException();}
void m2() throws WhiteException {throw new WhiteException();}
public static void main (String[] args) {
White white = new White();
int a,b,d,f; a = b = d = f = 0;
try {white.m1(); a++;} catch (WhiteException e) {b++;}
try {white.m2(); d++;} catch (WhiteException e) {f++;}
System.out.print(a+","+b+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,1,0,0 |
| b. | Prints: 1,1,0,1 |
| c. | Prints: 0,1,0,1 |
| d. | Prints: 0,1,1,1 |
| e. | Prints: 1,1,1,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Brown {
public static void main(String args[]) {
int a, b, c, d, f; a = b = c = d = f = 0;
int x = 1;
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level3Exception e) {b++;}
catch (Level2Exception e) {c++;}
catch (Level1Exception e) {d++;}
finally {f++;}
System.out.print(a+","+b+","+c+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,1,1 |
| b. | Prints: 0,0,1,1,1 |
| c. | Prints: 0,1,1,1,1 |
| d. | Prints: 1,1,1,1,1 |
| e. | Prints: 0,0,1,0,1 |
| f. | Prints: 0,1,0,0,1 |
| g. | Prints: 1,0,0,0,1 |
| h. | Compile-time error |
| i. | Run-time error |
| j. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Brown {
public static void main(String args[]) {
int a, b, c, d, f; a = b = c = d = f = 0;
int x = 2;
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level3Exception e) {b++;}
catch (Level2Exception e) {c++;}
catch (Level1Exception e) {d++;}
finally {f++;}
System.out.print(a+","+b+","+c+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,1,1 |
| b. | Prints: 0,0,1,1,1 |
| c. | Prints: 0,1,1,1,1 |
| d. | Prints: 1,1,1,1,1 |
| e. | Prints: 0,0,1,0,1 |
| f. | Prints: 0,1,0,0,1 |
| g. | Prints: 1,0,0,0,1 |
| h. | Compile-time error |
| i. | Run-time error |
| j. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Brown {
public static void main(String args[]) {
int a, b, c, d, f; a = b = c = d = f = 0;
int x = 4;
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level3Exception e) {b++;}
catch (Level2Exception e) {c++;}
catch (Level1Exception e) {d++;}
finally {f++;}
System.out.print(a+","+b+","+c+","+d+","+f);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,1,1 |
| b. | Prints: 0,0,1,1,1 |
| c. | Prints: 0,1,1,1,1 |
| d. | Prints: 1,1,1,1,1 |
| e. | Prints: 0,0,1,0,1 |
| f. | Prints: 0,1,0,0,1 |
| g. | Prints: 1,0,0,0,1 |
| h. | Compile-time error |
| i. | Run-time error |
| j. | None of the above |
class ColorException extends Exception {}
class WhiteException extends ColorException {}
abstract class Color {
abstract void m1() throws ColorException;
}
class White extends Color {
void m1() throws WhiteException {throw new WhiteException();}
public static void main (String[] args) {
White white = new White();
int a,b,c; a = b = c = 0;
try {white.m1(); a++;}
catch (WhiteException e) {b++;}
finally {c++;}
System.out.print(a+","+b+","+c);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0 |
| b. | Prints: 0,0,1 |
| c. | Prints: 0,1,0 |
| d. | Prints: 0,1,1 |
| e. | Prints: 1,0,0 |
| f. | Prints: 1,0,1 |
| g. | Prints: 1,1,0 |
| h. | Prints: 1,1,1 |
| i. | Compile-time error |
| j. | Run-time error |
| k. | None of the above |
class RedException extends Exception {}
class BlueException extends Exception {}
class White {
void m1() throws RedException {throw new RedException();}
public static void main (String[] args) {
White white = new White();
int a,b,c,d; a = b = c = d = 0;
try {white.m1(); a++;}
catch (RedException e) {b++;}
catch (BlueException e) {c++;}
finally {d++;}
System.out.print(a+","+b+","+c+","+d);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,1,0,0 |
| b. | Prints: 1,1,0,1 |
| c. | Prints: 0,1,0,1 |
| d. | Prints: 0,1,1,1 |
| e. | Prints: 1,1,1,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 1;
try {
throw new Level1Exception();
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1,1,1,0,0,1 |
| b. | Prints: 0,1,1,0,0,1 |
| c. | Prints: 0,1,0,0,0,0 |
| d. | Prints: 0,1,0,0,0,1 |
| e. | Prints: 0,0,1,0,0,1 |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |