Given the code fragments: What is the result?
A.
Super Sub Sub
B.
Compilation fails at line n2
C.
Contract Contract Super
D.
Compilation fails at line n1
Given the code fragments: What is the result?
A.
Super Sub Sub
B.
Compilation fails at line n2
C.
Contract Contract Super
D.
Compilation fails at line n1
A
Yes, A is correct, I tested with code
interface Contract{}
class Super implements Contract{};
class Sub extends Super{};
public class A106 {
public static void main(String[] args) {
// TODO Auto-generated method stub
List objs = new ArrayList();
Contract c1 = new Super();
Contract c2 = new Sub();
Super s1 = new Sub();
objs.add(c1);
objs.add(c2);
objs.add(s1);
for (Object object : objs) {
System.out.println(object.getClass().getName());
}
}
}
a
tested