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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why packages are used?

906


What is the main purpose of java?

778


Can one thread block the other thread?

820


Is ++ operator is thread safe in java?

716


What is meant by final class?

793


What is java ceil?

799


When to use runnable interface vs thread class in java?

771


What is the synchronized method modifier?

881


Can an interface implement another interface?

801


How does a for loop work?

762


What means public static?

803


What is a method vs function?

780


What is __ init __ functions?

811


Write a program to calculate factorial in java?

788


What is an argument java?

738