-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChild.java
More file actions
43 lines (32 loc) · 1.22 KB
/
Child.java
File metadata and controls
43 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Basic Java overriding scenarios.
package org.aadi;
class Parent {
public void abc(){
System.out.println("Parent method abc()");
}
public void abc1(){
System.out.println("Parent method abc1()");
}
}
public class Child extends Parent {
public void abc(){
System.out.println("Child overridden method abc()");
}
public void abc2(){
System.out.println("Child method abc2()");
}
public static void main(String []args){
//Parent p = new Parent();
//p.abc(); //Parent method abc()
//p.abc1(); //Parent method abc1()
//p.abc2(); //Error
//Parent p = new Child();
//p.abc(); //Child overridden method abc()
//p.abc1(); //Parent method abc1()
//p.abc2(); //Error
//Child c = new Child();
//c.abc(); //Child overridden method abc()
//c.abc1(); //Parent method abc1()
//c.abc2(); //Child method abc2()
}
}