Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 interface I { 2 String s1 = \"I\"; 3 } 4 class A implements I { 5 String s1 =

ID: 3714209 • Letter: 1

Question

1 interface I {

2 String s1 = "I";

3 }

4 class A implements I {

5 String s1 = "A";

6 }

7 class B extends A {

8 String s1 = "B";

9 }

10 class C extends B {

11 String s1 = "C"; 12  

13 void printIt() {

14 System.out.print(((A)this).s1  

+ ((B)this).s1  

+ ((C)this).s1

+ ((I)this).s1);

15 }  

16

17 public static void main (String[] args) { 18 new C().printIt();

19 }

20 }

}}

What is the result of attempting to compile and run the program?

Prints: ABCI

Run-time error

Compile-time error

None of the above

Explanation / Answer

a. It prints ABCI on to the screen

Since we are typecasting currect Object to objects of superclass and accessing the variables, we won't get any error