forked from Mohanapriya2105/Review1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram
More file actions
31 lines (28 loc) · 725 Bytes
/
Program
File metadata and controls
31 lines (28 loc) · 725 Bytes
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
class Parent {
void show() { System.out.println("Parent's show())
}
// Inherited class
class Child extends {
// This method overrides show() of Parent
@Override void show();
{
System.out.println( Child's show());
}
}
// Driver class
class Main {
public static void main(String[] args)
{
// If a Parent type reference refers
// to a Parent object, then Parent's
// show is called
Parent obj1 = new Parent();
obj1.show();
// If a Parent type reference refers
// to a Child object Child's show()
// is called. This is called RUN TIME
// POLYMORPHISM.
Parent obj2 = new Child();
obj.show();
}
}