Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

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.

52.

A static nested class is _____________ class in behavior that is nested in another _________ class.(a) Top level, top level(b) Top level, low level(c) Low level, top level(d) Low level, low levelThe question was asked in a job interview.Enquiry is from Nested Class in portion Class Members & Types of Object Oriented Programming

Answer»

Right option is (a) Top level, top level

The explanation: Top level CLASS encloses the other classes or have same preference as that of other top level classes. Having a class inside the top level class is INDIRECTLY having a top level class which HIGHER DEGREE of encapsulation.