fork download
  1. class supcon
  2. {
  3. private int x,y;
  4. supcon(supcon obj)
  5. {
  6. x=obj.x;
  7. y=obj.y;
  8. }
  9. supcon(int a,int b)
  10. {
  11. x=a;
  12. y=b;
  13. }
  14. void display()
  15. {
  16. System.out.println("value of x is :" + x);
  17. System.out.println("value of y is :" + y);
  18. }
  19. }
  20. class subcon extends supcon
  21. {
  22. private int z;
  23. subcon(subcon obj)
  24. {
  25. super(obj);
  26. z=obj.z;
  27. }
  28. subcon(int a,int b,int c)
  29. {
  30. super(a,b);
  31. z=c;
  32. }
  33. void display()
  34. {
  35. super.display();
  36. System.out.println("value of z is :" +z);
  37. }
  38. }
  39. class exsuper
  40. {
  41. public static void main(String[] args)
  42. {
  43. subcon obj=new subcon(10,20,30);
  44. obj.display();
  45. }
  46. }
Success #stdin #stdout 0.08s 212416KB
stdin
Standard input is empty
stdout
value of x is :10
value of y is :20
value of z is :30