CONSTRUCTOR OVERLOADING WITHOUT PARAMETER, SINGLE PARAMETER, MULTIPLE PARAMETER
import java.util.Scanner;
class day
{
int
a;
day()
{
System.out.println("Sunday");
}
day(int
x)
{
System.out.println("Monday");
}
day(int
x,int y)
{
System.out.println("Friday");
}
}
class day1
{
public
static void main(String args[])
{
day
ob1=new day();
day
ob2=new day(5);
day
ob3=new day(7,9);
}
}
Output:
E:\>javac day1.java
E:\>java day1
Sunday
Monday
Friday
E:\>
No comments:
Post a Comment