

MCQOPTIONS
Saved Bookmarks
1. |
package testpkg.p1; public class ParentUtil { public int x = 420; protected int doStuff() { return x; } } package testpkg.p2; import testpkg.p1.ParentUtil; public class ChildUtil extends ParentUtil { public static void main(String [] args) { new ChildUtil().callStuff(); } void callStuff() { System.out.print("this " + this.doStuff() ); /* Line 18 */ ParentUtil p = new ParentUtil(); System.out.print(" parent " + p.doStuff() ); /* Line 20 */ } } which statement is true? |
A. | The code compiles and runs, with output this 420 parent 420. |
B. | If line 18 is removed, the code will compile and run. |
C. | If line 20 is removed, the code will compile and run. |
D. | An exception is thrown at runtime. |
Answer» D. An exception is thrown at runtime. | |