If more than one class is created in the program, but only a main method is called in main class. Then what will be happen?

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:


Post a Comment

Previous Post Next Post