Skip to content

Commit 723ce92

Browse files
Added Method overriding in java
1 parent d940c16 commit 723ce92

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Method overriding : If derived class has the same method as declared in the base class, it is known as method overriding.
3+
*/
4+
5+
class base
6+
{
7+
void display()
8+
{
9+
System.out.println("This is base class display method");
10+
}
11+
}
12+
class derived extends base
13+
{
14+
void display() //overriding base class display method
15+
{
16+
System.out.println("This is derived class display method");
17+
}
18+
19+
}
20+
public class meth_overiding {
21+
public static void main(String[] args)
22+
{
23+
derived dob = new derived();
24+
base bob = new base();
25+
dob.display();
26+
}
27+
}

0 commit comments

Comments
 (0)