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
What are unchecked exceptions in java?
What is tochararray in java?
How to print nodes of a Binary tree?
List the different types of classloaders in java.
If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?
Does java arraylist maintain insertion order?
What is the final keyword?
What is the purpose of using the java bean?
What is an interface in java? Explain
Can list contain null in java?
What is java algorithm?
What is the collection interface?
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
Can we override the static method?
How to set the permissions to a file in java?