We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 57f8f66 commit f1f8c8dCopy full SHA for f1f8c8d
src/inheritance/Animal.java
@@ -0,0 +1,3 @@
1
+class Animal {
2
+ String family = "cats";
3
+}
src/inheritance/Cat.java
@@ -0,0 +1,28 @@
+
+class Cat extends Animal {
+ 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
20
21
22
23
24
25
26
27
28
0 commit comments