-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabCompre_Soln2.java
72 lines (57 loc) · 1.31 KB
/
LabCompre_Soln2.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Solution of question 2 from OOPs Lab Compre held on 12th Dec 2023.
import java.util.*;
abstract class Animal {
private String name;
public Animal(String name) {
this.name = name;
}
public abstract void greets();
}
class Cat extends Animal {
public Cat(String name) {
super(name);
}
public void greets() {
System.out.println("Meow");
}
}
class Dog extends Animal {
public Dog(String name) {
super(name);
}
public void greets() {
System.out.println("Woof");
}
public void greets(Dog Dog) {
System.out.println("Wooooof");
}
}
class BigDog extends Dog {
public BigDog(String name) {
super(name);
}
public void greets() {
System.out.println("Woow");
}
public void greets(Dog Dog) {
System.out.println("Wooooow");
}
public void greets(BigDog BigDog) {
System.out.println("Wooooooooow");
}
}
class pgm {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
Cat c = new Cat("Cattie");
Dog d = new Dog("Doggie");
BigDog d1 = new BigDog("Big Doggie");
c.greets();
d.greets();
d.greets(d);
d1.greets();
d1.greets(d);
d1.greets(d1);
sc.close();
}
}