- class Demo
- {
- int a;
- int b;
- Demo(int x, int y)
- {
- a=x;
- b=y;
- }
- public static void main (String...a)
- {
- Demo d1=new Demo(10,20);
- System.out.println(d1.a);
- System.out.println(d1.b);
- }
- }
- Output:
- 10
- 20
- class Constrctr
- {
- int a,b,c,d,e;
- Constrctr (int a1, int b1, int c1, int d1, int e1)
- {
- a=a1;
- b=b1;
- c=c1;
- d=d1;
- e=e1;
- }
- void show()
- {
- System.out.println(a);
- System.out.println(b);
- System.out.println(c);
- System.out.println(d);
- System.out.println(e);
- }
- Constrctr (Constrctr t)
- {
- a=t.a;
- b=t.b;
- c=t.c;
- d=t.d;
- e=t.e;
- }
- public static void main(String...a)
- {
- Constrctr c1 = new Constrctr(1,2,3,4,5);
- Constrctr c2 = new Constrctr(c1);
- c1.show();
- c2.show();
- }
- }
- Output:
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
- class Constrctr
- {
- int a,b,c,d,e;
- Constrctr (int a, int b, int c, int d, int e)
- {
- this.a=a;
- this.b=b;
- this.c=c;
- this.d=d;
- this.e=e;
- }
- void show()
- {
- System.out.println(a);
- System.out.println(b);
- System.out.println(c);
- System.out.println(d);
- System.out.println(e);
- }
- Constrctr (Constrctr t)
- {
- a=t.a;
- b=t.b;
- c=t.c;
- d=t.d;
- e=t.e;
- }
- public static void main(String...a)
- {
- Constrctr c1 = new Constrctr(1,2,3,4,5);
- Constrctr c2 = new Constrctr(c1);
- c1.show();
- c2.show();
- }
- }
- Output : >
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
| Copyright ©2016 | All Rights Reserved |
| Design by Uves Khan |