int y,x=1,total=0; while(x<=3){ y=x*x;
System.out.println(y); total+=y; ++x; }
System.out.println(\ }
}
3.下列程序段的运行结果为_____10.0_________。
class Q1{
public static void main(String args[ ]){ double d=10;
Dec dec=new Dec( ); dec.decrement(d); System.out.println(d); } }
class Dec{
public void decrement(double decMe){ decMe = decMe -5;
}
}
4.下列程序段的运行结果为______________。 public class abc{
public static void main(String args[ ]){
SubSubClass x = new SubSubClass(10 , 20 , 30);
x.show(); } }
class SuperClass{
int a,b;
SuperClass(int aa , int bb){
a=aa; b=bb; }
void show( ) {
System.out.println(\ }
}
class SubClass extends SuperClass{
int c;
SubClass(int aa,int bb,int cc){
super(aa,bb); c=cc;
} }
class SubSubClass extends SubClass {
int a;
SubSubClass(int aa,int bb,int cc) {
super(aa,bb,cc); a=aa+bb+cc;
}
void show(){
System.out.println(\ }
}
5.下列程序段的运行结果为____234__________。
第6页 共3页
public class Test{
public static void foo(int i){ try{
if(i==1){
throw new Exception(); }
System.out.print(\ }catch(Exception e){
System.out.print(\ }finally{
System.out.print(\ }
System.out.print(\ }
public static void main(String[] args){ foo(1); }
}
图2
第7页 共3页
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库《Java面向对象程序设计》考试卷及答案带注释(2)在线全文阅读。
相关推荐: