-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain1.java
More file actions
48 lines (45 loc) · 674 Bytes
/
Main1.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
class Fruit
{
String name, taste,size;
Fruit(String n,String t,String s){
name = n;
taste = t;
size = s;
}
public void eat()
{
System.out.println(name + " tastes " + taste + " is " + size);
}
}
class Apple extends Fruit
{
Apple(String n,String t,String s)
{
super(n,t,s);
}
public void print()
{
super.eat();
}
}
class Orange extends Fruit
{
Orange(String n,String t,String s)
{
super(n,t,s);
}
public void print()
{
super.eat();
}
}
class Main1
{
public static void main(String args[])
{
Apple obj1 = new Apple("Apple", "sweet", "big");
Orange obj2 = new Orange("Orange", "bitter", "small");
obj1.print();
obj2.print();
}
}