Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3a38b5d

Browse files
Updated Inheritance
1 parent cb5e3f8 commit 3a38b5d

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Animal{
2+
public void eat(){
3+
System.out.println("Eating");
4+
}
5+
}
6+
7+
class Dog extends Animal{
8+
public void bark(){
9+
System.out.println("Barking");
10+
}
11+
}
12+
13+
class Cat extends Animal{
14+
public void meow(){
15+
System.out.println("Meowing");
16+
}
17+
}
18+
19+
class hierarchialinheritance{
20+
public static void main(String[] args){
21+
Cat yu = new Cat();
22+
yu.eat();
23+
yu.meow();
24+
//yu.bark(); // Compile Time Error
25+
}
26+
}

‎Object Oriented Programming/L3 - Inheritance/Inheritance.MD‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,30 @@ Weeping<br>
135135
When two or more classes inherits a single class is called Hierarchial Inheritance.
136136

137137
```
138+
class Animal{
139+
public void eat(){
140+
System.out.println("Eating");
141+
}
142+
}
138143
144+
class Dog extends Animal{
145+
public void bark(){
146+
System.out.println("Barking");
147+
}
148+
}
149+
150+
class Cat extends Animal{
151+
public void meow(){
152+
System.out.println("Meowing");
153+
}
154+
}
155+
156+
class hierarchialinheritance{
157+
public static void main(String[] args){
158+
Cat yu = new Cat();
159+
yu.eat();
160+
yu.meow();
161+
//yu.bark(); // Compile Time Error
162+
}
163+
}
139164
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /