class Building { }
public class Barn extends Building {
public static void main(String[] args) {
Building build1 = new Building();
Barn barn1 = new Barn();
Barn barn2 = (Barn) build1;
Object obj1 = (Object) build1;
String str1 = (String) build1;
Building build2 = (Building) barn1;
}
}
Which is true?
A. If line 10 is removed, the compilation succeeds.
B. If line 11 is removed, the compilation succeeds.
C. If line 12 is removed, the compilation succeeds.
D. If line 13 is removed, the compilation succeeds.
E. More than one line must be removed for compilation to succeed.
Answer: C
Não entendi pq uma instancia de Building pode ser convertida para Barn, de acordo com o que eu havia entendido, essa conversão só funcionaria se build1 fosse a Barn =/