1.

In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?(a) Protected(b) Private(c) Public(d) StaticThe question was posed to me by my college director while I was bunking the class.This intriguing question originated from Inheritance in chapter Inheritance of Java

Answer»

The correct answer is (b) Private

Explanation: By declaring VARIABLE private, the variable will not be AVAILABLE in inherited to SUBCLASS.



Discussion

No Comment Found

Related InterviewSolutions