Is there is any error if you have multiple main methods in
the same class?

Answer Posted / aburar yaseen

we can use multiple main methods in a class by overloading
and not by the overriding. but the overriding is possible
in case of parent child combination.

example:
class xxx{

public static void main(String args[]){}
void main(){}
}
the above is called overloading.

example2;
class xxx{
public static void main(String args[]){}
}
class yyy extends xxx{
public static void main(String args[]){}
}
the above is overriding.
example3;
class xxx{
public static void main(String args[]){}
public static void main(String args[]){}
}
the example3 is not possible
}

Is This Answer Correct ?    16 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does || mean in vectors?

478


Why do we need strings in java?

529


How can we make copy of a java object?

548


What is string pool?

629


Explain the difference between runnable and callable interface in java?

590






How to declare an arraylist in java?

482


what is difference betweem home interface and remote interface?

2120


What is a variable and constant?

550


What is deserialization?

587


Which programming language is most secure?

536


How we can generate random numbers in java?

612


What is the collections api?

578


What is get () in java?

573


What two classes are used to read data only?

645


In the below example, how many string objects are created?

561