-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (29 loc) · 738 Bytes
/
Main.java
File metadata and controls
34 lines (29 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Animal { // Superclass (parent)
public void animalSound() {
int int0 =2;
System.out.println("The animal makes a sound" + int0);
}
private int a, b;
public Animal(int va, int vb) {
a=va;
b=vb;
}
public Animal() {
a=0;
b=0;
}
}
class Dog extends Animal { // Subclass (child)
public void animalSound() {
super.animalSound(); // Call the superclass method
System.out.println("The dog says: bow wow");
}
}
public class Main {
public static void main(String args[]) {
Animal myDog = new Dog(); // Create a Dog object
myDog.animalSound(); // Call the method on the Dog object
Animal AniHa = new Animal();
// AniHa.a =3 ;
}
}