USE OF CONSTRUCTOR OVERLOADING USING JAVA PROGRAM - Carrier Study

Breaking

Home Top Ad

Responsive Ads Here

Saturday, May 26, 2018

USE OF CONSTRUCTOR OVERLOADING USING JAVA PROGRAM

class test
{
int a,b;
test()
{
a=25;
b=40;
}
test (int x){
a=b=x;
test (int x, int y)
{
a=x;
b=y;
}
void show()
{
system.out.println("a value :"+a);
system.out.println("b value :"+b);
}
class extest
{
public static void main(string args[])
{
test t1=new test();
test t2=new test(25);
test t3=new test(50,100);
system.out.println("t1 object");
t2.show();
system.out.println("t3.object");
t3.show();
}
}

No comments:

Post a Comment