//https://csprograms4u.blogspot.com/
//Chapter 3
//Program 4
//Constructor Overloading
public class CO
{
int x;
double y;
String z;
CO(int a,double b)//parameterized
constructor
{
x=a;
y=b;
}
CO(String s,int i,double d)
{
z=s;
x=i;
y=d;
}
void D1()
{
System.out.println(x+"\t"+y);
}
void D2()
{
System.out.println(z+"\t\t"+x+"\t"+y);
}
public static void main(String args[])
{
CO obj = new CO(12,13.6);
obj.D1();
System.out.print("\n");
CO obj1 = new
CO("sukhvir",24,78.3);
obj1.D2();
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.