static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()
第1题:
2下列程序实现对ZIP 文件file.zip 的检索,在横线处填入正确的语句是( )。package test;import java.io.*;import java.util.*; import java.util.zip.*;public class Exam{ public static void main(String[] args){ try{ FileInputStream fis = new FilelnputStream("test/file.zip"); ZipInputStream zis = new ZiplnputStream(fis); ZipEntry en; while ((______ )!= null){ en.getName(); zis.closeEntry(); } zis.close(); } catch(Exception e){ e.pfintStackTrace(); }}
A.en = zis. getNextEntry()
B.en == zis.getNextEntry(
C.en=zis. getEntry()
D.zis.getNextEntry()
第2题:
根据输出结果填空完成下面程序。
include<iostream.h>
class Test
{
private:
static int val;
int a;
public:
static int func( );
void sfunc(Test &r);
};
______//初始化静态变量val
int Test::func( )
{
return val++;
}
void Test::sfunc(Test &r)
{
r.a=125;
cout<<"Result3="<<r.a;
}
void main( )
{
cout<<"Resultl="<<Test::func( )<<endl;
Test A;
cout<<"Result2="<<A.fune( )<<endl;
A. sfunc(A);
}
输出结果为:
Result1=201
Result2=202
Result3=125
第3题:
有如下类定义:
class Test
{
public:
Test(){ a = 0; c = 0;} // ①
int f(int a)const{this->a = a;} // ②
static int g(){return a;} // ③
void h(int
B . {Test::b = b;}; // ④
private:
int a;
static int b;
const int c;
};
int Test::b = 0;
在标注号码的行中,能被正确编译的是
A . ①
B . ②
C . ③
D . ④
第4题:
已知有下面的类说明: public class Test4 { private float f=1.0f; int m=12; static int n=1; public static void main(String args[]) { Test4 e=new Test4(); } } 在main()方法中,下面哪个的使用是正确的? ( )
A.e.f
B.this.n
C.Test4.m
D.Test4.f
第5题:
已知有下列类的说明,则下列哪个语句是正确的?public class Test { private float f=1.0f; int m=12; static int n=1; public static void main(String arg[]) { Test t= new Test(); }}
A.t.f;
B.this. n
C.Test.m;
D.Test.f;
第6题:
请在下划线处填入代码,是程序正常运行并且输出 “ Hello! ”
Class Test 【 15 】 {
Public static void main (String[] arge){
Test t = new Test();
t.start();
}
Public void run(){
System.out.println( “ Hello! ” );
}
第7题:
A.t.f
B.this.n
C.Test.m
D.Test.n
第8题:
下列程序段的输出结果是【 】。
public class Test {
void printValue(int m) {
do {
System.out.println("The value is"+m);
}while (--m>10);
}
public static void main (String args[]) {
int i=10;
Test t= new Test();
t.printValue(i);
}
}
第9题:
已知有下列类的说明,则下列( )语句是正确的。 publicClass Test{ private float f=1.0f; int m=12; static int n=1: public static void main(Stringarg[]){ Test t=new Test(): } }
A.t.f;
B.this.n;
C.Test.m;
D.Test.f;
第10题:
使下列程序正常运行并且输出“Hello!”,横线处应填写的内容是( )。 class Test { public static void main(string[]args){ Test t=new Test; start; } Public void run{ System.out.println("Hello!¨); )
A.extends Thread
B.extends Float
C.extends Iostream
D.extends Stdio