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 are unchecked exceptions in java?

598


What is tochararray in java?

492


How to print nodes of a Binary tree?

1747


List the different types of classloaders in java.

495


If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?

654






Does java arraylist maintain insertion order?

536


What is the final keyword?

542


What is the purpose of using the java bean?

555


What is an interface in java? Explain

563


Can list contain null in java?

615


What is java algorithm?

511


What is the collection interface?

577


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?

595


Can we override the static method?

562


How to set the permissions to a file in java?

528