Knowee
Questions
Features
Study Tools

Which is correct?I. Inner classes don’t have access to private members of the enclosing class.II. Inner class can’t be declared with the “private” access modifier.III. A static nested class is just like any other top-level class.*Only III.Only I.Only I and III.Only II and III.All

Question

Which is correct?I. Inner classes don’t have access to private members of the enclosing class.II. Inner class can’t be declared with the “private” access modifier.III. A static nested class is just like any other top-level class.*Only III.Only I.Only I and III.Only II and III.All

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct answer is "Only III."

Explanation:

I. Inner classes do have access to all private members of the enclosing class. So, statement I is incorrect.

II. Inner classes can be declared with the "private" access modifier. So, statement II is incorrect.

III. A static nested class is indeed just like any other top-level class. It can be accessed without having to instantiate the outer class, just like a static method. So, statement III is correct.

This problem has been solved

Similar Questions

Which of the following statements is true about static nested classes?Question 4Answera.They can access non-static methods and variables of the outer class directly.b.They can be instantiated without an instance of the outer class.c.They can only be declared within static methods.d.They can be inherited by the subclasses of the outer class.

Which of the following statement/s are correct?I. The access modifier “private” can be used with every class.II. Default access level is less restrictive than the protected access level.III. The only access modifier which can be used inside a method is public.*Only II.Only III.Only I and II.Only I and III.None of above

Private Constructors• A private constructor is a special instanceconstructor.• It is generally used in classes that contain staticmembers only.• If a class has one or more private constructors andno public constructors, other classes (except nestedclasses) cannot create instances of this class

Which of the following statements is true about static variables?Question 4Answera.They cannot be accessed outside the class.b.They are accessible only within the static methods.c.They are created for each instance of a class.d.They are shared among all instances of a class.

Which of the following statements is correct?Public method is accessible only to subclasses of its parent classPublic method can only be called by object of its classPublic method is accessible to all other classes in the hierarchyPublic method can be accessed by calling object of the public class

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.