Leave a Reply 1

Your email address will not be published. Required fields are marked *


renko

renko

Answer: C

Code question:
import java.util.ArrayList;

public class Ref {
public static void main(String[] args) {
ArrayList objs = new ArrayList();

Contract c1 = new Super();
Contract c2 = new Sub(); //ln1
Super s1 = new Sub();

objs.add(c1);
objs.add(c2);
objs.add(s1); //ln2

for (Object itm: objs) {
System.out.println(itm.getClass().getName());
}
}

}
public interface Contract {}

public class Super implements Contract{}

public class Sub extends Super {}

Output:
Super
Sub
Sub
BUILD SUCCESSFUL (total time: 0 seconds)