Why does java not allow multiple public classes in a java file ?

Answers were Sorted based on User's Feedback



Why does java not allow multiple public classes in a java file ?..

Answer / sushila sonare

suppose in java file so many classes, interfaces, abstract
classes and enumerations are there. we can keep only one of
them as a public because its shown a container and this
container we are keeping all things in our java file.

if we kept public for more then one class then all are that
classes qualified as a container or we are called it
execution unit. again compiler get confuse which container
classes has to kept. So avoiding this confusion multiple
public classes are not allowed in java.

Is This Answer Correct ?    0 Yes 0 No

Why does java not allow multiple public classes in a java file ?..

Answer / rahul

java does not support multiple public classes because of there are only one main method to define......and we can not have multiple main methods in a same class....and we know that java code will always save as the name of class name in which main method are define......

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More Core Java Interview Questions

What are the five major types of reference sources?

0 Answers  


What is java util list?

0 Answers  


when,where and how to use abstract class and interface

2 Answers  


What is the purpose of a parameter?

0 Answers  


Describe what happens when an object is created in java ?

0 Answers  






what is the output ? Math.floor(-2.1) a)2 b)-2 c)-3.0 d)0

4 Answers   Accenture,


Can you make a constructor final in Java?

0 Answers   SwanSoft Technologies,


How will you add panel to a frame?

0 Answers  


What is balanced tree in java?

0 Answers  


What is string [] java?

0 Answers  


What is rule of accessibility in java?

0 Answers  


Explain about exception propagation?

0 Answers  


Categories