Skip to content

Commit 7a1ae00

Browse files
committed
Experiment 4_1
1 parent 86b1cc9 commit 7a1ae00

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Exp-04 part 1 :Inheritance
2+
import java.io.*;
3+
4+
//Super Class
5+
class Fruit {
6+
private String season = new String("Summers"); //Private Access Modifier
7+
int price = 80;
8+
void getprice(){
9+
System.out.println(price);
10+
}
11+
}
12+
//Sub Class
13+
class Mango extends Fruit {
14+
String name = new String("Mango");
15+
}
16+
17+
public class Exp4_1 extends Fruit {
18+
public static void main (String[] args) {
19+
Mango obj = new Mango();
20+
obj.getprice();
21+
// System.out.print(obj.season);
22+
23+
}//main
24+
}//test

0 commit comments

Comments
 (0)