Ans: more than one classes are being called then only main method of main class will be run.
There will be no problem to create more than a class is being created. But all classes will be compiled.
Program:
// define a class A, in which no main method
class A
{
}
// define a class B, in which no main method
class B
{
}
// define a class C, in which no main method
class C
{
}
// define a class Six, in which main method is called
class Six
{
//main method is being called
public static void main(String args[])
{
//call print function
System.out.println("hello java");
}
}
Sample output: