-
Notifications
You must be signed in to change notification settings - Fork 0
/
qb17.java
63 lines (45 loc) · 1.03 KB
/
qb17.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
// QB-17
abstract class vegetable {
String color;
public abstract String toString();
}
class potato extends vegetable {
String color;
public potato(String color) {
this.color = color;
}
// Override
public String toString() {
return "potato color is " + color;
}
}
class brinjal extends vegetable {
String color;
public brinjal(String color) {
this.color = color;
}
// Override
public String toString() {
return "brinjal color is " + color;
}
}
class tomato extends vegetable {
String color;
public tomato(String color) {
this.color = color;
}
// Override
public String toString() {
return "tomato color is " + color;
}
}
class Main {
public static void main(String[] args) {
potato p = new potato("Yellow");
brinjal b = new brinjal("Violet");
tomato t = new tomato("Red");
System.out.println(p);
System.out.println(b);
System.out.println(t);
}
}