1.

How many public class(s) (outermost) can be there in a java program?(a) 1(b) 2(c) 3(d) As requiredThe question was posed to me in exam.My question is taken from Public Access Specifier in chapter Access Specifiers of Object Oriented Programming

Answer»

The correct choice is (a) 1

To explain I WOULD say: There can be only ONE public class in a java program. The public class name MUST MATCH the name of file. And there can’t be more than one class with same name in a SINGLE program in same scope. Hence it is not possible to have more than one public class in java program.



Discussion

No Comment Found

Related InterviewSolutions