fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. class J{
  13. private int x, y;
  14. public J() { x = y = 3;}
  15. public void fun() { x = y = 6; }
  16. public int back() { return 1; }
  17. public String toString() {
  18. return x + " " + y;
  19. }
  20. }
  21.  
  22. class K extends J {
  23. public void fun() { System.out.println(back()); }
  24. public String toString() {
  25. return "class K " + super.toString();
  26. }
  27. }
  28.  
  29. class M{
  30. private int x, y;
  31. public M() { x=8; y=1; }
  32. public double fun() { return x; }
  33. public double go() { return y; }
  34. public double back() { return fun(); }
  35. public String toString() {
  36. return x + " " + y;
  37. }
  38. }
  39.  
  40. class N extends M{
  41. public N() { }
  42. public double fun() { return 7; }
  43. public double go() { return super.back(); }
  44. public double back() { return 2; }
  45. public String toString() {
  46. return super.toString();
  47. }
  48. }
  49.  
  50. //////////////////////////////////////////////
  51. //test code in the main method
  52. J one = new J();
  53. System.out.println(one);
  54. one = new K();
  55. one.fun();
  56. System.out.println(one);
  57.  
  58. M two = new M();
  59. System.out.println(two.go());
  60. System.out.println(two.back());
  61. System.out.println(two.fun());
  62. System.out.println(two);
  63. two = new N();
  64. System.out.println(two.go());
  65. System.out.println(two.back());
  66. System.out.println(two.fun());
  67. System.out.println(two);
  68.  
  69. }
  70. }
Success #stdin #stdout 0.12s 36440KB
stdin
Standard input is empty
stdout
3 3
1
class K 3 3
1.0
8.0
8.0
8 1
7.0
2.0
7.0
8 1