Skip to content

Commit f1f8c8d

Browse files
committedAug 4, 2022
add inheritance folder and its files
1 parent 57f8f66 commit f1f8c8d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 

‎src/inheritance/Animal.java

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Animal {
2+
String family = "cats";
3+
}

‎src/inheritance/Cat.java

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
class Cat extends Animal {
3+
void meow(){
4+
System.out.print("meow");
5+
}
6+
7+
public static void main(String[] args) {
8+
9+
Cat mingming = new Cat();
10+
11+
//family is coming from Animal class
12+
System.out.print("call from Animal class, family is : `");
13+
System.out.print(mingming.family);
14+
System.out.println("`");
15+
16+
//meuw method is from Cat class
17+
System.out.print("call from Cat class, method will `");
18+
mingming.meow();
19+
System.out.println("`");
20+
21+
}
22+
23+
}
24+
25+
26+
27+
28+

0 commit comments

Comments
 (0)
Please sign in to comment.