Method Overloading in java

METHOD OVERLOADING 



Method overloading means more than one methods and different arguments(Parameters).
  • Static method is data members.
  • Static method is mandatory.
  • Without main method not executing the program.
  • Main method is not mandetory for compilation.
Program:-

class Demo
 {
public static void main(String [] a)
{
     Demo d1=new Demo();
     //d1.main();
     //Demo.main();
 //main();
System.out.println("Hello");

main(10);

}

public static void main()
{
System.out.println("main method");
}
public static void main(int a)
{
System.out.println("another method");
}
}

Output:-

main method
Hello
another method












Comments

Post a Comment

Popular posts from this blog

#Coding || Java || Inheritance

#Constructor

# How to write java program #Structure || Java Program