JAVA面试题-深圳易思博.doc_第1页
JAVA面试题-深圳易思博.doc_第2页
JAVA面试题-深圳易思博.doc_第3页
JAVA面试题-深圳易思博.doc_第4页
JAVA面试题-深圳易思博.doc_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

BroadenGate Systems Inc. 深圳市易思博软件技术有限公司JAVA开发工程师面试题(一) 备注: 请不要在试卷上打草稿! 请将答案填在答题纸上,100分钟内完成1. 根据这个类选择所有正确的内部类:(多选)ABCclass 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 = +i); d. class B class A e. class A 2. 下列所给出的声明中,什么会写入标准输出中?(单选)DSystem.out.println(4 | 7)?a. 4b. 5c. 6d. 7e. 03. 下列有关方法notify()(用于和wait()连接)的正确描述是:(单选)Aa. if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified.b. if there is more than one thread 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 not strictly necessary to own the lock for the object you invoke notify () for.e. Notify () should only be invoked from within a while loop.4. 给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:(多选)Aclass Apublic int x;private int y;class Bprotected void method1()class Cprivate void method2()class d extends Apublic float z;a. The variable x defined in Ab. The variable y defined in Ac. method () defined in Bd. The variable z defined in D5. 你有一个用ISO 88598定义的8位字符串文档,当你要在文本域中写一个显示该文档的应用,而局部编码已经设置成ISO 88598时,你如何写一段代码来读取该文档的第一行?(你有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()方法的声明是错误的?(多选)DEa. 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,你可以添加哪一个执行接口?(多选)ABa. ActionListenerb. FocusListenerc. MouseMotionListenerd. WindowListenere. ContainerListener8. 当你试着编译和运行下面的程序时,结果怎样?(单选)Eclass MyTestString 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. 试分析以下两行代码:(多选)ACDfloat f = 3.2;int i = f;a. This code would not compile.b. This code would compile and i would 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;在下面init()方法给出的applet中,用户接口将出现什么情况?(单选)CsetLayout(new BorderLayout();add (new Button(hello);a. Nothing will appear in the applet.b. A button will appear in the applet set int the exact center.c. A button will appear in the applet along the top and centered horizontally.d. A button will appear in the top left corner.10. 如果你在JDK1.2下想要用值将关键字联系起来,则以下哪个类位首选?(多选)BDa. Dictionaryb. HashTablec. Propertiesd. HashMape. TreeMap11. 定义一个名为Key的无继承类正确方法是?(单选)Ea. class Keyb. abstract final class Keyc. native class Keyd. class Keyfinal;e. final class Key12. 下列哪一个能代表一个octal number?(单选)Da. 0x12b. 320c. 032d. (octal)2e. 1213. 当你运行Tester2类时,将得到什么标准输出结果?(单选)Eclass Tester2int 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. nothingb. helloc. 5d. hello following by good-byee. good-bye followed by hello14. 根据提供如下代码,如果方法tryThis() 发生一个 NumberFormatException,将得到什么标准结果?(单选)try BtryThis();return;catch(IOException x1)System.out.println(exception 1);return;catch(Exception x2)System.out.println(exception 2);return;finallySystem.out.println(finally);a. Nothingb. exception 1 followed by finallyc. exception 2 followed by finallyd. exception 1e. exception 215. 给出如下代码,如果此snippet在标准输出中显示为90,则method()调用了何种数学方法?(单选)Cdouble a = 90.7;double b = method(a);System.out.println(b);a. absb. minc. floord. rounde. ceil16. 如果Ran.test文档并不存在,而你试图编译并运行以下代码时,将会发生什么情况?(单选)Dimport java.io.*;class Ranpublic static void main(String args) throws IOExceptionRandomAccessFile out = new RandomAccessFile(Ran.test,rw);out.writeBytes(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 it creates.17. 当你创建一个新的线程时,如果提供一个目标对象,TargetObject是什么类型的实例才能作为合法参数传入:Thread t = new Thread(targetObject); Ca. targetObject instanceof Threadb. targetObject instandeof Objectc. targetObject instanceof Appletd. targetObject instanceof Runnablee. targetObject instanceof String18. 给出如下的代码片断,哪一个表达式为合法的Java表达式,且返回值为真?(单选):BBoolean b1 = new Boolean(true);Boolean b2 = new Boolean(true);a. b1 = b2b. b1.equals(b2)c. b1 & b2d. b1 | b2e. b1 & b2f. b1 | b219. 下列哪一个布局管理器以从左至右,然后从上到下,以每一行为中心移动的方式排列组件? (单选)Ca. BorderLayoutb. FlowLayoutc. GridLayoutd. CardLayoute. GridBagLayout20. 下列哪一个关于垃圾收集的描述是正确的?(多选)BCa. 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 when it is about to be garbage collected.d. The garbage collector reclaims an objects memory as soon as it becomes a candidate for garbage collection.e. The garbage collector runs in low-memory situations.21. Given this interface definition:根据该界面定义,下列哪一个类能实现该接口并且不是抽象类?(多选)interface Aint method1(int i);int method2(int j);class B implements Aint method1()int method2()b. class B int method1(int i)int method2(int j)c. class B implements Aint method1(int i)int method2(int j)d. class B extends Aint method1(int i)int method2(int j)e. class B implements Aint method1(int j)int method2(int i)22. Examine the following switch block根据如下的转换流,下列哪个命题是正确的?(多选)BEchar 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 only integers 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.23. 如果你编译,运行以下类,将会出现什么情况?(单选)Cclass Teststatic int myArg = 1;public static void main(String args)int myArg;System.out.println(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.24. 如果你用名为c的变量为引用组件调用addContainerListener()函数,请估计下列哪个表达式将为这个问题提出正确或错误的回答?(单选) Ca. c = Containerb. c.equals(Class.Container)c. c instanceof Containerd. c instanceof Componente. c implements Container25. 当下列程序运行“java Mystery Mighty Mouse”命令时将得到什么结果?(单选)Ajava Mystery Mighty Mouseclass Mysterypublic static void main(String args)Changer c = new Changer();c.method(args);System.out.println(args0 + + args1);static class Changervoid method(String s)String temp = s0;s0 = s1;s1 = 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. 26. 根据提供的如下代码,请问在/A处应该补充什么代码该程序可以标准输出单词running? (单选)Cclass RunTest implements Runnablepublic static void main(String args)RunTest rt = new RunTest();Thread t = new Thread(rt);/Apublic void run() Systme.out.println(running);void go()start(1);void start(int i)a. System.out.println(running);b. rt.start();c. rt.go();d. rt.start(1);27. 分析下面的一行代码,选择一个正确的回答(单选Aif(5 & 7 0 & 5 | 2) System.out.println(true);a. This line of code will not compile.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.28. 请选出有关在Component类中定义的paint()方法所有正确的描述:(单选)Ba. It is protected.b. It takes an instance of class Graphics.c. It is static.d. It is invoked automatically whenever you minimize and then maximize a component, such as a window.e. There is also a version that takes an int.29. 分析以下代码,选择所有正确的答案。(单选)Dvoid looper()int x = 0; one: while(x 3) break two; 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 numbers 5 through 9 to the standard output.h. This method writes the number 10 to the standard output.30. 根据下面的程序 判断出正确的表达式?(单选)Bint arr = 1,2,3;for (int i=0;i2;i+) arri=0; a. arr0=0b. arr0=1c. arr1=1d. arr2=0e. arr3=031. 下列关于try, catch和finally的正确描述是?(多选)BCa. 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.32. 创建一个新的RandomAccessFile对象的合法模式是?(多选).BDa. w b. r c. x d. rw33. 当你试图编译和运行这段代码时,将得到什么结果?(单选)Aabstract class Baseabstract public void myfunc();public void another()System.out.println(Another method);public class Abs extends Basepublic static void main(String argv)Abs a = new Abs();a.amethod();public void myfunc()System.out.println(My Func);public void amethod()myfunc();a. The code will compile and run, printing out the words My Funcb. 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 body, nobody at all to leave it. 34. 以下哪一个是java modifiers(多选)ABa. public b. private c. friendly d. transient e. vagrant35. 当你试图编译和运行这段代码时,将得到什么结果? (单选)Cpublic class Modpublic 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.36. 当你试图编译和运行这段代码时,将得到什么结果? (单选)Aprivate class Basepublic class Vistransient 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.37. 当你试图编译和运行这段代码时,将得到什么结果?(单选)Dpublic class Bground extends Threadpublic static void main(String args)Bround b = new Bgound();b.run();public void start()for(int i=0;i10;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.38. 如何使一个线程停止执行? (单选)Aa. The program exits via a call to System.exit(0).b. Another thread is given a higher priority.c. A call to the threads stop method.d. A call to the halt method of the Thread class.39. 下列哪一个是JVM执行垃圾收集命令的正确语法? (单选)Da. System.free();b. System.setGarbageCollection();c. System.out.gc();d. System.gc();40. 当你试图用命令“hello there”编译和运行这段代码时,将得到什么结果?(单选)Apublic class ArgString MyArg;public static void main(String args)MyArg = argv;public void amethod()System.out.println(argv1);a. Compile time error.b. Compilation and output of hello.c. Compilation and output of there.d. None of the above.41. 当你试图编译和运行这段程序时,将得到什么结果?(单选)Cpublic class Outerpublic String name=Outer;public static void main(String argv)Inner i = new Inner();i.showName(); /End of mainprivate class InnerString name = new String(Inner);void showName()System.out.println(name); /End of Inner classa. 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.42. 当你试图编译和运行这段代码时,将得到什么结果?(单选)Aimport java.awt.event.*;import java.awt.*;public class MyWc extends Frame imp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论