1.

Which among the following is true for public class?(a) There can be more than one public class in a single program(b) Public class members can be used without using instance of class(c) Public class is available only within the package(d) Public classes can be accessed from any other class using instanceI got this question in homework.I want to ask this question from Public Access Specifier in chapter Access Specifiers of Object Oriented Programming

Answer»

Right option is (d) Public classes can be accessed from any other class USING INSTANCE

To explain: The public class is a USUAL class. There is no special RULE but the members of the class can be accessed from other classes using instance of the class. This is USUALLY useful to define main() function.



Discussion

No Comment Found

Related InterviewSolutions