1.

If a declaration of a member in inner class has the same name as that in the outer class, then ________________ enclosing scope.(a) Outer declaration shadows inner declaration in(b) Inner declaration shadows outer declaration in(c) Declaration gives compile time error(d) Declaration gives runtime errorI have been asked this question in class test.I'd like to ask this question from Nested Class topic in portion Class Members & Types of Object Oriented Programming

Answer»

Correct choice is (B) Inner declaration shadows outer declaration in

The best I can explain: The inner class will have more preference for its LOCAL MEMBERS than those of the enclosing members. Hence it will shadow the enclosing class members. This process is known as SHADOWING.



Discussion

No Comment Found

Related InterviewSolutions