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 Parent{
  9.  
  10. public int display(String str, int... data)throws Exception{
  11.  
  12. String s = "(String, int[])";
  13.  
  14. System.out.println("Parent "+str + " " + s);
  15.  
  16. return 1;
  17.  
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24. class Child extends Parent{
  25.  
  26. public int display(String str, int... data){
  27.  
  28. String s = "(String, int[])";
  29.  
  30. System.out.println("Overridden: "+ str+" " +s);
  31.  
  32. return 0;
  33.  
  34. }
  35.  
  36.  
  37.  
  38. public static void main(String[] args) {
  39.  
  40. try {
  41.  
  42. Parent sb = new Child();
  43.  
  44. sb.display("Welcome", 5);
  45.  
  46. }
  47.  
  48. catch(Exception e) {
  49.  
  50.  
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }
  57.  
  58.  
Success #stdin #stdout 0.13s 50656KB
stdin
Standard input is empty
stdout
Overridden: Welcome (String, int[])