14.
Given:
class Bird {
{ System.out.print("bl "); }
public Bird() { System.out.print("b2 "); }
}
class Raptor extends Bird {
static { System.out.print("r1 "); }
public Raptor() { System.out.print("r2 "); }
{ System.out.print("r3 "); }
static { System.out.print("r4 "); }
}
class Hawk extends Raptor {
public static void main(String[] args) {
System.out.print("pre ");
new Hawk();
System.out.println("hawk ");
}
}
What is the result?
pre b1 b2 r3 r2 hawk
pre b2 b1 r2 r3 hawk
pre b2 b1 r2 r3 hawk r1 r4
r1 r4 pre b1 b2 r3 r2 hawk
r1 r4 pre b2 b1 r2 r3 hawk
pre r1 r4 b1 b2 r3 r2 hawk
pre r1 r4 b2 b1 r2 r3 hawk
The order of output cannot be predicted.
Compilation fails.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment