Skip to content

Commit b5a9b69

Browse files
Merge pull request PrajaktaSathe#158 from riyapandey730/Patch-1
Overriding
2 parents 14d772a + f5d6ea1 commit b5a9b69

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Programs/Overriding.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Human{
2+
//Overridden method
3+
public void eat()
4+
{
5+
System.out.println("Human is eating");
6+
}
7+
}
8+
class Boy extends Human{
9+
//Overriding method
10+
public void eat(){
11+
System.out.println("Boy is eating");
12+
}
13+
public static void main( String args[]) {
14+
Boy obj = new Boy();
15+
//This will call the child class version of eat()
16+
obj.eat();
17+
}
18+
}

0 commit comments

Comments
 (0)