Can u overload main()method.Give with example.
Answer Posted / kuldeep
yes it is possible in java but jvm call only one main()
method. for eg.
class test
{
public static void main(String []ar)
{
System.out.println("his is 1 st main() method");
}
public static void main(String ar[],String []st)
{
System.out.print("overloaded main() method");
}
}
but o/p of this program is: 1st main() method statement is
display. but why its ans. is at complile time String ar
argument contain one argument it is class name for making a
class file or byte code file. 2 arg store the one class
name it is not possible
| Is This Answer Correct ? | 9 Yes | 3 No |
Post New Answer View All Answers
what happens when a thread cannot acquire a lock on an object? : Java thread
Can two objects have same hashcode?
Can we use synchronized block for primitives?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
How to sort list of list in java?
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
Is 0 an even number?
What is a java predicate?
What is abstraction in java?
which class is the wait() method defined in? : Java thread
Define jre i.e. Java runtime environment?
Which class should you use to obtain design information about an object in java programming?
What is variable declaration and definition?
What is the advantage of OOP in java?
What is main method?