-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 815.java
More file actions
39 lines (32 loc) · 771 Bytes
/
QB 815.java
File metadata and controls
39 lines (32 loc) · 771 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
35
36
37
38
39
//QB 815
class vegetable {
public String color; // instatnce color accesible to all classes (public)
}
class potato extends vegetable {
public String toString() {
color = "Yellow";
return "potato " + color;
}
}
class brinjal extends vegetable {
public String toString() {
color = "Violet";
return "brinjal " + color;
}
}
class tomato extends vegetable {
public String toString() {
color = "Red";
return "tomato " + color;
}
}
class vegies {
public static void main(String[] args) {
potato p = new potato();
brinjal b = new brinjal();
tomato t = new tomato();
System.out.println(p);
System.out.println(b);
System.out.println(t);
}
}