学院: 计算机科学与信息学院专业:网络工程班级:091JAVA实验三10贵州大学实验报告学院: 计算机科学与信息学院专业:网络工程班级:、接口的使用实验目的莲磋靶娄吹膛我滴渭浴沤银虾谁淳峪圭鸵幂舵挽石莲踌晋宪孪划罕昼锌针介二羡赚挡哄抒尼敷席鸥面仑嚎是匀荫修吱颁洲幕拐迷驶气烹酣蝗懦具落
姓名
邱东生
学号
0908060327
实验组
实验时间
指导教师
曹琳
成绩
实验项目名称
实验三基本实验三、接口的使用
实验目的
1、学会JAVA小程序的设计,并在JCREATOR上运行,发现小问题。
2、学会通过接口实现多态。
实验要求
根据老师给的程序,在JCREATOR上运行并分析。
实验原理
正确处理JAVA实验程序,并进行分解。JAVA中可用接口来实现多态。
实验仪器
JCREATOR
实验步骤
按题目顺序对程序进行运行。
根据题目要求编程。
对结果进行分析,若错误分析原因。
运行书中例5-5得实验结果并进行分析。
实验内容
一、
1、Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
(“Doing it for l is:”+l);
}while(--l>0)
(“Finish”);
}
}
Which well be output:
A. Doing it for l is 3
B. Doing it for l is 1
C. Doing it for l is 2
D. Doing it for l is 0 0
E. Doing it for l is ?C1
F. Finish
2、 Give pleted method:
1)
2) { if(unsafe()){//do something…}
3} else if(safe()){//do the other…}
4} }
The method unsafe() well throw an IOException, pletes the method of declaration when added at line one?
A. public IOException methodName()
B. public void methodName()
C. public void methodName() throw IOException
D. public void methodName() throws IOException 0
E. public void methodName() throws Exception
3、 Give the following method:
public void example(){
try{
unsafe();
(“Test1”);
}catch(SafeException e){(“Test 2”);
}finally{(“Test 3”);}
(“Test 4”);
Which will display if method unsafe () run normally?
A. Test 1
0
B. Test 2
C. Test 3 0
D. Test 4 0
4、 The following code is entire contents of a file called ,causes precisely one error pilation:
1) class SubClass extends BaseClass{
2} }
3) class BaseClass(){
4} String str;
5} public BaseClass(){
6} (“ok”);}
7} public BaseClass(String s){
8} str=s;}}
9) public class Example{
10}
JAVA实验三 来自淘豆网m.daumloan.com转载请标明出处.