Sunday, January 31, 2016

TestConstructor1

package Constructor;

public class TestConstructor1 extends TestConstructor{

int a;
int b;
int c;

TestConstructor1() {
super();
System.out.println("I am default constructor");
}

TestConstructor1(int a) {
this.a = a;
System.out.println("I am integer constructor");
}

TestConstructor1(String a) {

System.out.println("I am String constructor");
}

TestConstructor1(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}

void display() {

System.out.println("The value of a, b, c is:-" + a + "," + b + "," + c);
}

public static void main(String[] args) {
// TODO Auto-generated method stub

TestConstructor1 obj1 = new TestConstructor1(5);
TestConstructor1 obj2 = new TestConstructor1("Bhanu");
TestConstructor1 obj = new TestConstructor1(2, 3, 4);

obj.display();
}

}

1 comment:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Java Training in Electronic city

    ReplyDelete