Engineering Full Stack Apps with Java and JavaScript
Given:
interface I { } class A implements I { } class B extends A { } class C { } public class TestClass1 { public static void main(String[] args) { I i = new B(); B b = new B(); C c = new C(); if (i instanceof I) System.out.println("i is a I"); if (b instanceof A) System.out.println("b is a A"); if (c instanceof A) System.out.println("c is a A"); } }
What will be printed when the above code is compiled and run?
Select 1 option
A. It will not compile.
B. It will throw an exception when run.
C. i is a I
b is a A
D. i is a I
E. b is a A
F. c is a A