Given:
class Emu {
static String s = "-";
public static void main(String[] args) {
try {
throw new Exception();
} catch (Exception e) {
try {
try { throw new Exception();
} catch (Exception ex) { s += "ic "; }
throw new Exception(); }
catch (Exception x) { s += "mc "; }
finally { s += "mf "; }
} finally { s += "of "; }
System.out.println(s);
} }
What is the result?
-ic of
-mf of
-mc mf
-ic mf of
-ic mc mf of
-ic mc of mf
Compilation fails.
15.
Given:
class Mineral { }
class Gem extends Mineral { }
class Miner {
static int x = 7;
static String s = null;
public static void getWeight(Mineral m) {
int y = 0 / x;
System.out.print(s + " ");
}
public static void main(String[] args) {
Mineral[] ma = {new Mineral(), new Gem()};
for(Object o : ma)
getWeight((Mineral) o);
}
}
And the command-line invocation:
java Miner.java
What is the result?
null
null null
A ClassCastException is thrown.
A NullPointerException is thrown.
A NoClassDefFoundError is thrown.
An ArithmeticException is thrown.
An IllegalArgumentException is thrown.
An ArrayIndexOutOfBoundsException is thrown.
16.
Which are most typically thrown by an API developer or an application developer as opposed to being thrown by the JVM? (Choose all that apply.)
ClassCastException
IllegalStateException
NumberFormatException
IllegalArgumentException
ExceptionInInitializerError
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment