- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain1.java
More file actions
Latest commit
48 lines (45 loc) · 674 Bytes
/
Copy pathMain1.java
File metadata and controls
48 lines (45 loc) · 674 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
40
41
42
43
44
45
46
47
48
classFruit
{
Stringname, taste,size;
Fruit(Stringn,Stringt,Strings){
name = n;
taste = t;
size = s;
}
publicvoideat()
{
System.out.println(name + " tastes " + taste + " is " + size);
}
}
classAppleextendsFruit
{
Apple(Stringn,Stringt,Strings)
{
super(n,t,s);
}
publicvoidprint()
{
super.eat();
}
}
classOrangeextendsFruit
{
Orange(Stringn,Stringt,Strings)
{
super(n,t,s);
}
publicvoidprint()
{
super.eat();
}
}
classMain1
{
publicstaticvoidmain(Stringargs[])
{
Appleobj1 = newApple("Apple", "sweet", "big");
Orangeobj2 = newOrange("Orange", "bitter", "small");
obj1.print();
obj2.print();
}
}