[考试说明:本试卷为深圳易思博选人的试题,学员不得带走]
一、选择题(2分/题)
1、根据这个类选择所有正确的内部类:(多选) class A {
protected int I; A(int i){ This.i=I; } } a. class B{ } b. class B extends A{ } c. class B{ B(){ System.out.println(“i=”+1); } } d. class S{ class A{ } } e. class A{ }
2、下列所给出的声明中,什么会写入标准输出中?(单选) System.out.println(4|7)?
a.4 b.5 c.6 d.7 e.0
3、下列有关方法notify()(用于和wait()连接)的正确描述是:(单选)
a. if there is more than one thead waiting on a condition,only the thread that has been waiting the longest is notified.
b. if there is more than one thead waiting on a condition,there is no way to predict which thread will be notified.
c. Notify() is defined in the Thread class.
d. It is notstrictly necessary to own the lock for the object you invoke notify() for.
e. Notify() should only be invoked form within a while loop.
4、给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:(多选) class A { public int x; private int y; class B {
protected void method1(){ }
class C {
privated void method2() { } }
长沙一度软件教育中心
} }
class d axtends A{ public float z; }
a. The variable x defined in A b. The variable y defined in A c. Method() defined in B
d. The variable z defined in d
5、你有一个用ISO 8859-8定义的8位字符串文档,当你要在文本域中写一个显示该文档的应用,而局部编码已经设置成ISO 8859-8时,你如何写一段代码来读取该文档的第一行? (你有3个可获取的变量)
a. InputStreamReader reader=new InputStreamReader(stream,"8859-8"); BufferedReader buffer=new BufferedReader(reader); S=buffer.readLine();
b. InputStreamReader reader=new InputStreamReader(stream); BufferedReader buffer=new BufferedReader(reader); S=buffer.readLine();
c. InputStreamReader reader=new InputStreamReader(myfile,"8859-8"); BufferedReader buffer=new BufferedReader(reader); S=buffer.readLine();
d. InputStreamReader reader=new InputStreamReader(myfile); BufferedReader buffer=new BufferedReader(reader); S=buffer.readLine();
e. FileReader reader=new FileReader(myfile);
BufferedReader buffer=new BufferedReader(reader); S=buffer.readLine();
6、哪一个对单机程序中的main()方法的声明是错误的?(多选) a. public static void main()
b. public static void main(String[] string) c. public static void main(string args) d. static public int main(String[] args) e. static void main(String[] args)
7、作为文本框对象的listeners,你可以添加哪一个执行接口?(多选) a. ActionListener b. FocusListener
c. MouseMotionListener d. WindowListener e. ContainerListener
8、当你试着编译和运行下面的程序时,结果怎样?(单选)
长沙一度软件教育中心
class MyTest{ String s;
Public static void main(String[] args){ MyTest m=new MyTest(); m.go(); }
void MyTest(){ s=“constructor”; }
void go(){
System.out.println(s); }
a. This code will not compile.
b. This code compiles but throws an exception at runtime c. This code runs but nothing appears in the standard output d. This code runs and “constructor” in the standard output e. This code runs and writes “null”in the standard output
9.试分析以下两行代码:(多选) float f=3.2; int I=f;
a. This code would not compile
b. This code would compile and iwould be set to 3.
c. The second line would compile if it were written instead as:int I = (byte)if d. The first line would compile if it were written instead as:float f= 3.2F
10.在下面init()方法给出的applet中,用户接口将出现什么情况?(单选) public void init(){
setlayout(new BorderLayout()) add(new Button(“hello”)) }
a. Nothing will appear in the applet
b. Abutton will appear in the applet set int the exact center.
c. Abutton will appear in the applet along the top and centered horizontally. d. Abutton will appear in the top left corner.
11.如果你在JDK1.2X下想要用值将关键字联系起来,则以下哪个类位首选?(多选) a. Dictionary b. HashTable c. Properties d. HashMap e. TreeMap
12.定义一个名为key的无继承类正确方法是?(单选)
长沙一度软件教育中心
a. class Key{}
b. abstract final class Key{} c. native class Key{} d. class Key{ final }
e. finai class Key{}
13.下列哪一个能代表一个octalnumber?(单选) a. 0x12 b. 320 c. 032 d. (octal)2 e. 12
14.当你运行tester2类时,将得到什么标准输出结果?(单选) class Tester2{ int var
Tester(double var){ This.var =(int)var }
Tester(int var){ This(“hello”) }
Tester(String S ){ this ();
System.out.println(s); }
Tester(){
System.out.println(“good-bye”); }
public static void main(String[] args){ Tester t = new Tester(5); } }
a. nothing b. “hello” c. 5
d. “hello”following by “good -bye” e. “good-bye”following by “hello”
15. 根据提供如下代码,如果方法 try This() 发生一个NumberFormatException,将得到什么标准结果?(单选) try{
长沙一度软件教育中心
tryThis();
return;}catch(IOException x1){ System.out.println(“exception 1”); Return;} catch(Exception x2){ System.out.println(“exception 2”); Return; }finally{
System.out.println(“finally”); }
a. nothing
b. “exception 1”following by “finally” c. “exception 2”following by “finally” d. “exception 1” e. “exception 2”
16.给出如下代码,如果此snippet 在标准输出中显示为90,则method()调用了何种数学方法?(单选) double a=90.7;
double b=method(a); System.out.println(b); a. abs b. min c. floor d. round e. cell
17.如果”Ran.test”文档并不存在,而你试图编译并运行一下代码时,将会发生什么情况?(单选)
import java.io.*; class Ram{
public static void main()(String[] args) throws IOExcetion {
RandomAccessFile.out = new RandomAccessFile (“Ran.test”,”rw”); Out.wntebytes(“Ninotchka”); } }
a. The code dose not compile because RandomAccessFile is not created correctly.
b. The code dose not compile because RandomAccessFile dose not implement the writeBytes()
method.
c. The code compiles and runs but throws IOException because “ran.test”does not yet exist. d. The code compiles and runs but nothing appears int the file “ran.test”that it creates. e. The code compiles and runs and “Ninotchka”appears in the file “ran.test” that is creates.
18.当你创建一个新的线程时,如果提供一个目标对象,TargetObject是什么类型的实例才能作为合法参数传入;
长沙一度软件教育中心
Thread t=new Thread(targetObject); a. targetObject instanceof Thread. b. targetObject instanceof Object. c. targetObject instanceof Applet. d. targetObject instanceof Runnable e. targetObject instanceof String
19.给出如下的代码片断,哪一个表达式为合法的java表达式,且返回值为真?(单选); Boolean b1=new Boolean(true); Boolean b2=new Boolean(true); a. b1==b2
b. b1.equals(b2) c. b1&b2 d. b1 | b2 e. b1&&b2 f. b1 || b2
20.下列哪一个布局管理器以从左至右,然后从上到下,以每一行为中心移动的方式排列组件?(单选); a. BorderLayout b. FlowLayout c. GridLayout d. CardLayout e. GridBagLayout
21.下列哪一个关于垃圾收集的描述是正确的?(多选) a. You can directly free the memory allocated by an object
b. You can directly run the garbage collector whenever you want to. c. The garbage collector informs your object whenever you want to
d. The garbage collector reclaims an object`s memory as soon as it becomes a candidate for
garbage collection.
22.Given this interface definition;根据该界面定义,下列哪一个类能实现该接口并不是抽象类?(多选) interface A{
int method1(lnt I); int method2(int j); } ClassB ImplementsA{ Int method1(){} Int Method2(){} } a. classB{ int method1(int i){} int method2(int j){} } c. class B implementsA{ int method1(int i){} int method2(int j){} b. class c. class Bextends Bimplements A{ A{ int method1(int int i){} method1(int){} int method2(int int method2(int 长沙一度软件教育中心
} j){} I){} } 23、Examine the following switch block 根据如下的转换流,下列哪个命题是正确的?(多选) char mychar=’c’; switch(mychar){
default;
case’a’:System.out.println(“a”);break; case’b’:System.out.println(“b”);break; }
a、 This switch block is illegal,,because onlyintegers can be used in the switch statement. b、 This switch block is fine.
c、 This switch block is illegal,because the default statement must come last. d、 When this code runs,nothing is written to the standard output. e、 When this code runs,the letter”a”is written to the standard output.
24、如果你编译,运行以下类,将会出现什么情况?(单选) class Test{
static int myArg=1;
pubhc static vold main(String[]args){
int myArg;
System.out.printin(myArg); } }
a、 This code compiles and displays 0 in the standard output when run. b、 This code compiles and displays 1 in the standard output when run.
c、 This code does not compile because you cannot define a local variable named the same as a
static variable. d、 This code does not compile because the local variable is used before it is initialized.
25、如果你用名为c的变量为引用组件调用addContainerListener()函数,请估计下列哪个表达式将为这个问题提出正确或错误的回答?(单选) a、 C==Container
b、 c.equals(Class. Container) c、 c instanceof Container d、 c instanceof Component e、 c implements Container
26、当下列程序运行“java Mystery Mighty Mouse”命令时将得到什么结果?(单选) java Mystery Mighty Mouse
Class Mystery{
长沙一度软件教育中心
Bublic static void main(String[] args) {
Changer c=new Changer(); c.method(args);
System.out.printin(args[0]+””+args[1]); }
static class Changer {
void method(String [] s)
{
String temp=s[0]; s[0] = s[1]; s[1] = temp; } }
a. This program causes an ArrayIndexOutOfBoundsException to be thrown. b. This program runs but does not write anything to the standard output. c. This program writes “Myighty Mouse ” to the standard output. d. This program writes “Mouse Myighty “ to the standard output.
27根据提供的如下代码,请问在//A处应该补充什么代码该程序可以标准输出单词‘running’?(单选)
Class Run Test implements Runnable
{
public static void main(String [] args) {
RunTest rt = new RunTest(); Thread t = new Thread(rt); //A }
public void run() {
System.out.println(“running”); }
void go() {
start(1); }
void start (int i) { } }
a. System.out.println(“running”);
长沙一度软件教育中心
b. Rs.start(): c. Rt.go(); d. Rs.start(1);
28.分析下面的一行代码,选择一个正确的回答(单选) if(5&7 > 0&& 5|2)System.out.println(“true”);
a. This line of code will not nomplie.
b. This code will compile but nothing will appear in the standard output. c. This code will compile and write the word “true” in the standard output.
29.请选出有关在Component 类中定义的paint()方法所有正确的描述:(单选)
a. It is protected.
b. It takes an instance of class Graphics. c. It is static .
d. It is invoed automatically whenever you minimize and then maximize acomponent, such
as a window.
e. There is also a version that takes an int .
30 分析以下代码,选择所有正确的答案。(单选) void looper() {
int x=0; one;
while(x<10) { two;
Syatem.out.println(++x);
If(x>3)
Break twc; } } }
a. This code compiles.
b. This code does not compile.
c. This method writes the number 0 to the standard output
d. This method writes the number 1 and 2 to the standard output. e. This method writes the number 3 to the standard output. f. This method writes the number 4 to the standard output.
g. This method writes the number 5 through 9 to the standard output. h. This method writes the number 10 to the standard output.
31.根据下面的程序判断正确的表达式?(单选) int[ ] arr ={1,2,3}; for (int i=0; i<2; i++)
长沙一度软件教育中心
arr[i]= 0; a. arr[0]==0 b. arr[0]==1 c. arr[1]==1 d. arr[2]==0 e. arr[3]==0
32. 下列关于try, catch 和finally的正确描述是?(多选) a. A try block must always be followed by a catch block.
b. A try block can be followed either by a catch block or a finally block, or both. c. A catch block must always be associated with a try block.
d. A finally can never stand on its own(that is ,without being associated with try block). e. None of these are true.
33. 创建一个新的RandomAccessFile对象的合法模式是?(多选) a. “ w ” b. ” r ” c. ” x ” d. ”rw”
34. 当你试图编译和运行这段代码时,将得到什么结果?(单选) abstract class Base{
abstract public void myfunc(); public void another(){
System.out.println(“Another method”); } }
public class Abs extends Base{
public static void main (String argv[ ]){
Abs a =new Abs(); a.amethod(); }
public void myfunc(){
System.cut.println(“My Func”); }
public void amethod(){
myfunc(); } }
a. The Code will compile and run,printing out the words “My Func”
b. The compiler will complain that the Base class has non abstract methods.
c. The code will compile but complain at run time that the Base class has not abstract
methods.
d. The compiler will complain that the method myfunc in the base class has no baby,nobody
at all to leave it.
35. 以下哪一个是java modifiers(多选)
长沙一度软件教育中心
a.public b. private c. friendly d. transient e. vagrant
36. 当你试图编译和运行这段代码时,将得到什么结果?(单选) public class Mod{
public static void main (String [] argv[]){ }
public static native void amethod(); }
a. Error at compilation: native method cannot be static. b. Error at compilation native emthod must return value.
c. Compilation but error at run time unless you have made code containing native amethod
avaible.
d. Compilation and execution without error.
37. 当你试图编译和运行这段代码时,将得到什么结果?(单选) private class Base{} public class Vis{ transient int iVal;
public static void main (String elephant[]){ } }
a. Compile time error: Base cannot be private.
b. Compile time error indicating that an integer cannot be transient . c. Compile time error transient not a data type. d. Compile time error malformed main method.
38. 当你试图编译和运行这段代码时,将得到什么结果?(单选) public class Bground extends Thread{ public static void main(String[] args){
Bround b =new Bground(); b.run(); }
public void start(){
for (int i =0;i<10;i++)
System.out.println(“Value of i=”+i) } }
a. A compile time error indicating that no run method is defined for the Thread class. b. A run time error indicating that no run method is defined for the Thread class. c. Clean compile and at run time the values 0 to 9 are printed out. d. Clean compile but no output at runtime.
39. 如何使一个线程停止执行?(单选)
a. The program exits via a call to System.exit(0). b. Another thread is given a higher priority
长沙一度软件教育中心
c. A call to the thread’s stop method
d. A call to the halt method of the Thread class
40. 下列哪一个是JVM执行垃圾收集命令的正确语法?(单选) a. System.free();
b. System.setGarbagCollection(); c. System.out.gc(); d. System.gc();
41. 当你试图用命令“hello there”编译和运行这段代码时,将得到什么结果?(单选)public class Arg{ String [] MyArg;
public static void main (String[] argv){
MyArg=argv; }
public void amethod(){
System.out.println(argv[1]); } }
a. Compile time error.
b. Compilation and output of “hello”. c. Compilation and output of “there”. d. None of the above.
42. 当你试图编译和运行这段程序时,将得到什么结果?(单选) public class Outer{
public String name=”Outer”;
public static void main (String[] argv){
Inner i =new Inner(); i.showName(); }//End of main private class Inner{
String name=new String (“Inner”); Void showName(){
System.out.println(name); }
}//End of Inner class }
a. Compile and run with output of “Outer”. b. Compile and run with output of”Inner”
c. Compile time error because Inner is declared as private.
d. Compile time error because of the line creating the instance of Inner
43. 当你试图编译和运行这段代码时,将得到什么结果?(单选)
长沙一度软件教育中心
import java.awt.event.*; import java.awt.*;
public class MyWc extends Frame implements WindowListener{ public static void main (String[] args){
MyWc mwc=new MyWc(); }
public void windowClosing(WindowEvent we){
System.exit(0);
}//End of windowClosing public void MyWc(){ setSize(300,300);
setVisible(true); }
}//End of class
a. Error at compile time
b. Visible Frame created that that can be closed c. Compilation but no output at run time.
d. Error at compile time because of comment before import statements.
44. 当你试图编译和运行这段代码时,最完整的描述是哪个选项?(多选) public class MyAr{
public static void main(String[] args){
MyAr m = new MyAr(); m.amethod();
}
public void amethod(){
static int i ;
System.out.println(i); } }
a. Compilation and output of the value 0 .
b. Compile time error because i has not been initialized. c. Compilation and output of null d. Compile time error .
45. 下列哪一个是Java关键字?(单选) a. double b. Switch c. then
d. instanceof
46. 下列哪一个是Java关键字?(单选) System.out.println(010|4); a. 14
长沙一度软件教育中心
b. 0 c. 12 d. 6
47. 下列哪个类编译时不会出错?(多选) interface IFace{}
class CFace implements IFace{} class Base {}
public class ObRef extends Base{
public static void main (String[] args){
ObRef ob =new ObRef(); Base b = new Base(); Object o1=new Object(); IFace o2=new Cface(); } }
a. o1=o2; b. b=ob; c. ob=b; d. o1=b;
48. 下列哪个是线程类的方法?(多选) a. yieid()
b. sleep(long msec) c. go() d. stop()
49. 根据提供的如下代码,请问在//A处应该补充什么代码,该程序方可运行并且得到当前时间?
Hello! The time is now//A
a. <% new java.util.Date()%> b. new java.util.Date() c.<%=new java.util.Date()%> e. none of above
50. 根据以下的代码,如果hello.jsp已经在正确的目录下,请问在//A处应该补充什么代码该程序可以正常运行?(多选)
Going to include hello.jsp…
//A
长沙一度软件教育中心
a. 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务