a. Prints 9
b. Compiler error at line 5
c. Compiler error at line 6
d. None of the above
Solution : Choice C is the correct answer.
You cannot access the protected variable in the Parent class from the Child class using the parent class reference. The Child class does inherit the variable x, but it can be accessed only by an object reference of the Child class. There is no error at line 5. It is legal to refer to a class as packagename.classname even if the package is already imported. So choice B is incorrect.
Source : "Facebook community"
No comments:
Post a Comment