- class Base
- {
- void show()
- {
- {
- System.out.println("method of class Base");
- }
- }
- }
- class Son extends Base
- {
- void show()
- {
- System.out.println("method of class Son");
- }
- void access()
- {
- super.show();
- }
- public static void main (String ...x)
- {
- Son s1 =new Son();
- s1.access();
- }
- }
- Output:
- method of class Base
- class Dada
- {
- void show()
- {
- {
- System.out.println("Dada class");
- }
- }
- }
- class Pita extends Dada
- {
- void show()
- {
- System.out.println("Pita class");
- }
- void display2()
- {
- super.show();
- }
- }
- class Beta extends Pita
- {
- void display1()
- {
- super.show();
- }
- void show()
- {
- System.out.println("Beta class");}
- public static void main (String ...x)
- {
- Beta b1 =new Beta();
- b1.show();
- b1.display1();
- b1.display2();
- }
- }
- Output:
- Beta class
- Pita class
- Dada class
- class Mn
- {
- void show()
- {
- System.out.println("Show Mn");
- }
- }
- class Op extends Mn
- {
- void show()
- {
- System.out.println("Show Op");
- }
- public static void main(String...a)
- {
- Op p1=new Op();
- p1.show();
- }
- }
- Output:
- Show Op
- class Father
- {
- private void show()
- {
- System.out.println("method of Father");
- }
- }
- class Son extends Father
- {
- protected void show()
- {
- System.out.println("method of Son");
- }
- public static void main (String ...a)
- {
- new Son().show();
- }
- }
- Output:
- Exception in thread "main" java.lang.NullPointerException at Son.show(Father.java:12) at Son.main(Father.java:16)
- class Father
- {
- void show()throws ArithmeticException
- {
- System.out.println("method of Father");
- }
- }
- class Son extends Father
- {
- void show()throws ArithmeticException
- {
- System.out.println("method of Son");
- }
- public static void main (String ...a)
- {
- new Son().show();
- }
- }
| Copyright ©2016 | All Rights Reserved |
| Design by Uves Khan |