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 is java regex?

730


What is numel matlab?

987


What is int short for?

716


What is super in java?

761


How to access arraylist elements in java?

699


What’s the difference between constructors and other methods?

729


When is update method called?

877


What is the format specifier?

703


What is application system?

686


Can memory leak in java?

783


Is string is a data type in java?

798


Why javac is not recognized?

708


Can we have any code between try and catch blocks?

740


What makes a function well defined?

753


What is udp in java?

738