Card 3 / 37: package ocjp; import java.util.ArrayList; interface Universe{ public void doStuff(); } class Star{ public void doStuff(){ System.out.println("twinkling star"); } } class Sun extends Star implements Universe{ public void doStuff(){ System.out.println("Shinning sun"); } } public class Test { public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); Sun obj2 = new Sun(); Star obj3 = obj2; ((Sun) obj3 ).doStuff(); ((Star)obj2 ).doStuff(); ((Universe)obj2).doStuff(); } }
A)
Shining Sun Shining Sun Shining Sun
B)
Shining Sun Twinkling Star Shining Sun
C)
Compilation fails
D)
A ClassCastException is thrown at runtime
Answer:
A) Shining Sun Shining Sun Shining Sun
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
|