fork download
  1. class supcon1
  2. {
  3. private int a,b;
  4. supcon1(supcon1 sobj)
  5. {
  6. System.out.println("Base class constructor with object");
  7. a=sobj.a;
  8. b=sobj.b;
  9. }
  10. supcon1(int a1,int a2)
  11. {
  12. System.out.println("Base class constructor with argument");
  13. a=a1;
  14. b=b1;
  15. }
  16. void display()
  17. {
  18. System.out.println("a="+a+" b= "+b);
  19. }
  20. }
  21. class subcon1 extends supcon1
  22. {
  23. int c;
  24. subcon1(subcon1 suobj);
  25. super(suobj);
  26. System.out.println("sub class with object argument");
  27. c=suobj.c;
  28. subcon1(int a1, int b1, int c1)
  29. {
  30. super(a1,b1);
  31. c=c1;
  32. }
  33. void display()
  34. {
  35. System.out.println("value of c :"+c);
  36. }
  37. }
  38. class exsuper
  39. {
  40. public static void main(String args[])
  41. {
  42. subcon1 suobj1=new subcon1(10,20,30);
  43. subcon1 suobj2=new subcon1(40,50,60);
  44. subcon1 cpy=new subcon1(suobj2);
  45. supcon1 s1=new supcon1(39,40);
  46. s1.display();
  47. suobj1.display();
  48. suobj2.display();
  49. cpy.display();
  50. }
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:25: illegal start of type
        super(suobj);
        ^
Main.java:25: <identifier> expected
        super(suobj);
                   ^
Main.java:26: <identifier> expected
        System.out.println("sub class with object argument");
                          ^
Main.java:26: illegal start of type
        System.out.println("sub class with object argument");
                           ^
Main.java:27: <identifier> expected
        c=suobj.c;
         ^
5 errors
stdout
Standard output is empty