If a declaration of a member in inner class has the same name as that in the outer class, then ________________ enclosing scope.

Huỳnh Hiền

New member
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 error
 
Answer: b
Explanation: 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.
 

Tìm kiếm

Back
Top