-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
30 lines (26 loc) · 701 Bytes
/
test.java
File metadata and controls
30 lines (26 loc) · 701 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
package bishi;
import java.sql.SQLOutput;
import java.util.Scanner;
class Fruit{}
class Apple extends Fruit{}
class Jonathan extends Apple{}
class orange extends Fruit{}
public class test {
public static void main(String[] args) {
Fruit[] fruit=new Apple[10];
fruit[0]=new Apple();
fruit[1]=new Jonathan();
try{
fruit[0]=new Fruit();
System.out.println("add Fruit");
}catch (Exception e){
System.out.println("cant put");
}
try{
fruit[0]=new orange();
System.out.println("add org");
}catch (Exception e){
System.out.println("cant put or");
}
}
}