can we overload main method?

Answer Posted / atul

class mainoverloaded
{
public void main()
{
System.out.println("Hey");
}
public void main(int a)

{
System.out.println(a);
}
}
class maind
{
public static void main(String ah[])
{
mainoverloaded m=new mainoverloaded();
m.main();
m.main(10);
}

}
please execute this code.it is execute correctly.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to sort array of 0 and 1 in java?

723


What do you mean by platform independence? What is an interface?

768


Why should I use abstract class?

758


How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?

799


What are the important features of Java 9 release?

738


Why vector is used in java?

747


What is google full form?

742


Why strings in java are called as immutable?

755


Is null a string?

751


Is it possible for a yielded thread to get chance for its execution again?

711


What is ‘is-a ‘ relationship in java?

783


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

865


What is the gregoriancalendar class in java programming?

762


Can we declare the static variables and methods in an abstract class?

745


Why do we need array in java?

719