Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

The correct statement is: "Public method is accessible to all other classes in the hierarchy".

In object-oriented programming, a public method is accessible from any other class in the application. It does not restrict the visibility of the method to just the class or its subclasses, it can be accessed from any class in the application.

Similar Questions

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

Which of the following statements are incorrect?none of themprivate members of class can be accessed from subclasspublic members of class can be accessed by any code in the programprivate members of class can only be accessed by other members of the class

Accessing MethodsWhich of the following statement(s) is(are) correct?(Note that more than one option may be correct.)An object of a superclass can access the public methods of the same superclass (itself).An object of a subclass can access the public methods of the same subclass (itself).An object of a superclass can access the public methods of its subclass.An object of a subclass can access the public methods of its superclass.

Which of the following is false about protected class members?They begin with one underscoreThey can be accessed by subclassesThey can be accessed by name mangling methodThey can be accessed within a class

Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package? b) Protecteda) Publicd) All of the mentionedc) No Modifier

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.