can two class in a code be public??if yes then how??

Answers were Sorted based on User's Feedback



can two class in a code be public??if yes then how??..

Answer / sreejesh1987

One java source file must have only one top-level(top level means not an inner class) public class with the same name as the name of the source file .


You can have inner classes to a class which are public. Hence in this way it is possible to have more than one public class in a single file.

Is This Answer Correct ?    11 Yes 2 No

can two class in a code be public??if yes then how??..

Answer / siva

NO only one class should be public if we write multiple
classes in a same file.we can write multiple class files in
a single file.if main() is there in one of the classes then
it should be declare as public.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are concepts of OOPS and how are they implemented in Java?

2 Answers   KPIT,


What are access specifiers available in java?

0 Answers  


What is the difference between serialization and deserialization?

3 Answers   ABC,


What does int argc char * argv [] mean?

0 Answers  


what is diffrence between .NET and java?

2 Answers  






What is entry in java?

0 Answers  


What are the two major components of JDBC?

5 Answers   CMC, Mind Tree,


What is treeset in java?

0 Answers  


What is broken and continue statement?

0 Answers  


What is the difference between constructor and method?

4 Answers  


Why char array is preferred over string for storing password?

0 Answers  


What are byte codes?

0 Answers  


Categories