Why does java not allow multiple public classes in a java file ?
Answers were Sorted based on User's Feedback
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 |
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 |
Advantages of Inheritance in java.
What are Brief Access Specifiers and Types of Access Specifiers?
Explain different types of wrapper classes in java?
What is a stringbuffer?
Can we clone singleton class in java?
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.
What is the difference between the synchronized() & static synchronized()?
Differentiate between a constructor and a method? Can we mark constructors final?
Can a singleton class be inherited?
In which order the iterator iterates over collection?
what is the difference between pagecontext and servletcontext?
What is the difference between static binding and dynamic binding?