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
Do we need to manually write Copy Constructor?
How can a gui component handle its own events in java programming?
What is currentthread()?
What are streams in java 8?
What is boolean logic?
How can you set an applet’s height and width as a percentage?
Can a class have multiple constructors?
How to sort an array from smallest to largest java?
What is downcasting?
Can an interface extend a class?
Is a class subclass of itself?
Tell me are there implementations for sorting and searching in the java libarary?
What does isempty () do in java?
How do you make a thread in java?
Explain how to force the garbage collection in java.