JAVA英文面试题.doc_第1页
JAVA英文面试题.doc_第2页
JAVA英文面试题.doc_第3页
JAVA英文面试题.doc_第4页
JAVA英文面试题.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

JAVA英文面试题满分:100分 (考试时间:1个小时)一 选择题 (共20题,每题5分,共100分)l Question 1What will happen when you attempt to compile and run this code?abstract class Baseabstract public void myfunc() ;public void another()System.out.println(Another method);public class Abs extends Basepublic static void main(String argv)Base b= new Abs(); /Ab. myfunc(); /Bpublic void myfunc()System.out.println(My Func);public void amethod()myfunc();1 choice1) The code will compile and run, printing out the words My Func2) The compiler will complain error at /A.3) The compiler will complain error at /B.4) The compiler will complain error at other position.l Question 2What will be the output when the following code is compiled and run (Assuming written inside main)?String s1 = new String(amit);System.out.println(s1.replace(m,r);System.out.println(s1);String s3 = arit;String s4 = arit;String s2 = s1.replace(m,r);System.out.println(s2 = s3);System.out.println(s3 = s4);1 choiceA. aritamitfalsetrueB. aritarittruetrueC. amitamitfalsefalseD. aritarittruefalsel Question 3Given:What will happen if you compile/run the following code?class MyClassint x;MyClass(int i)x = i;public static void main(String args)MyClass m1 = new MyClass(100);MyClass m2 = new MyClass(100);System.out.println(m1=m2);if(m1.equals(m2)System.out.println(Both are equal);elseSystem.out.println(Both are not equal);1 choiceA. Compilation error: equals() method was not defined.B. true Both are equalC. false Both are equal.D. true Both are not equal.E. false Both are not equall Question 4Given:1. public class Foo 2. public static void main (String args) 3. StringBuffer a = new StringBuffer (“A”);4. StringBuffer b = new StringBuffer (“B”);5. operate (a,b);6. system.out.printIn(a + “,” +b);7. 8. static void operate (StringBuffer x, StringBuffer y) 9. x.append (y);10. y = x;11. 12. What is the result? 1 choiceA. The code compiles and prints “A,B”.B. The code compiles and prints “A,A”.C. The code compiles and prints “B,B”.D. The code compiles and prints “AB,B”.E. The code compiles and prints “AB,AB”.F. The code does not compile because “+” cannot be overloaded for StringBuffer.l Question 51. public class test 2. public static void add3 (Integer i) 3. int val = Value ( );4. val += 3;5. i = new Integer (val);6. 7.8. public static void main (String args ) 9. Integer i = new Integer (0);10. add3 (i);11. system.out.printIn (Value ( );12. 13. )What is the result?A. Compilation will fail.B. The program prints “0”.C. The program prints “3”.D. Compilation will succeed but an exception will be thrown at line 3.l Question 6Given:1. public class ConstOver 2. public ConstOver (int x, int y, int z) 3. 4. Which two overload the ConstOver constructor? (Choose Two)A. ConstOver ( ) B. Protected int ConstOver ( ) C. Private ConstOver (int z, int y, byte x) D. public Object ConstOver (int x, int y, int z) E. public void ConstOver (byte x, byte y, byte z) l Question 7Given:1. public class MethodOver 2. public void setVar (int a, int b, float c) 3. 4. Which two overload the setVar method? (Choose Two)A. private void setVar (int a, float c, int b) B. protected void setVar (int a, int b, float c) C. public int setVar (int a, float c, int b) (return a;)D. public int setVar (int a, int b, float c) (return a;)E. protected float setVar (int a, int b, float c) (return c;)l Question 8public class Teststatic public void main(String args)int counter = 0;doSystem.out.println(args+counter);while (counter args.length);A. This code causes compile time error.B. This code compiles without errors and works fine.C. This code always misses the last parameter passed to the program.D. This code compiles without error but will throw a run time exception.l Question 9class Parentclass Child extends Parentpublic String getChild()String name = child;return name;public static void main(String argv)Parent p = new Child();/Place your code here.What code placed after the comment /Place your code here. will result in calling the getChild()method resulting in the output of the string child?A. System.out.println(p.getChild();B. System.out.println();C. System.out.println(Parent)p.getChild();D. System.out.println(Child)p).getChild();l Question 10In the following code, What code should be placed after the comment /Here that will print out 5?public class MyClasspublic static void main(String argv)int x = 5;/Here3 choicesA. System.out.println(x+);B. System.out.println(+x);C. System.out.println(-x+1);D. System.out.println(x-);E. System.out.println(-x);l Question 11Which values of variable x will show Message 2?switch(x)case 1 :System.out.println(Message 1);case 2 :case 3 :System.out.println(Message 2);default :System.out.println(End);不定项A. 1B. 2C. 3D. 4E. Nonel Question 12Given the following code how could you invoke the Base constructor that will print out the stringbase constructor?class BaseBase(int i)System.out.println(base constructor);Base()public class Sup extends Basepublic static void main(String argv)Sup s = new Sup();/OneSup()/Twopublic void derived()/ThreeA. On the line After /One put Base(10);B. On the line After /One put super(10);C. On the line After /Two put super(10);D. On the line After /Three put super(10);l Question 13Given:class TestA String text;public TestA(String text) this.text=textpublic void start() System.out.println(”TestA”); public class TestB extends TestA public void start() System.out.println(”TestB”); public static void main(String args) (TestA)new TestB().start();What is the result?A. TestAB. TestBC. Compilation fails.D. An exception is thrown at runtime.l Question 14The argument to a switch statement must be _.A. intB. charC. shortD. stringE. bytel Question 15What will be the output when you compile and execute the following program?class Threadable implements Runnablepublic void run()for(int i = 0; i 300; i+)System.out.println(Threadable: Running.);class Base extends Threadpublic void run()for(int i = 0; i 300; i+)System.out.println(Base: Running.);static public void main(String a)Threadable aFace = new Threadable();Thread aThread = new Thread(aFace);aThread.start();new Base().start();A. Three hundred times Threadable: Running. followed by three hundred times Base:Running.B. Threadable: Running. in a loopC. Base: Running. in a loopD. Depends on the Operating System and on Virtual MachineE. Complication Errorl Question 16What will happen when you attempt to compile and run the following code?1. public class WrapperTest2. 3. public static void main(String args)4. 5. Boolean b1 = new Boolean(true);6. Boolean b2 = new Boolean(Java);7. Boolean b3 = new Boolean(null);8. Boolean b4 = new Boolean(true);9. System.out.println(b1 + , + b2 + , + b3 + , + b4);10. 11. A. Compiler error at line 6B. Compiler error at line 7C. Compiler error at line 8D. It will print - true, false, null, trueE. It will print - true, false, false, trueF. It will throw NullPointerException at runtimel Question 17Which of the following classes implement java.util.Map interface? 3 choicesA. HashtableB. HashMapC. DictionaryD. IdentityHashMapE. Vectorl Question 18What will be the output on compiling/running the following code?public class MyThread extends Threadpublic int run(int time)System.out.println(run() called);return 5;public static void main(String args)new MyThread().start();A. Compilation errorB. Runtime errorC. prints : run() calledD. No outputl Question 19What will be

温馨提示

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

评论

0/150

提交评论