`
Flyxiaowu
  • 浏览: 1168 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

英文面试题

阅读更多
例题1: 

  Choose the three valid identifiers from those listed below.

  A. IDoLikeTheLongNameClass

  B. $byte

  C. const

  D. _ok

  E. 3_case

  解答:A, B, D

  点评:Java中的标示符必须是字母、美元符($)或下划线(_)开头。关键字与保留字不能作为标示符。选项C中的const是Java的保留字,所以不能作标示符。选项E中的3_case以数字开头,违反了Java的规则。

  例题2:

  How can you force garbage collection of an object?

  A. Garbage collection cannot be forced

  B. Call System.gc().

  C. Call System.gc(), passing in a reference to the object to be garbage collected.

  D. Call Runtime.gc().

  E. Set all references to the object to new values(null, for example).

  解答:A

  点评:在Java中垃圾收集是不能被强迫立即执行的。调用System.gc()或Runtime.gc()静态方法不能保证垃圾收集器的立即执行,因为,也许存在着更高优先级的线程。所以选项B、D不正确。选项C的错误在于,System.gc()方法是不接受参数的。选项E中的方法可以使对象在下次垃圾收集器运行时被收集。




 例题3:
 Consider the following class:

  1. class Test(int i) {

  2. void test(int i) {

  3. System.out.println(“I am an int.”);

  4. }

  5. void test(String s) {

  6. System.out.println(“I am a string.”);

  7. }
  
  8.
  
  9. public static void main(String args[]) {

  10. Test t=new Test();

  11. char ch=“y”;

  12. t.test(ch);

  13. }

  14. }

  Which of the statements below is true?(Choose one.)

  A. Line 5 will not compile, because void methods cannot be overridden.

  B. Line 12 will not compile, because there is no version of test() that rakes a char argument.

  C. The code will compile but will throw an exception at line 12.

  D. The code will compile and produce the following output: I am an int.

  E. The code will compile and produce the following output: I am a String.

  解答:D

  点评:在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。

  例题4:

  Which of the following lines of code will compile without error?

  A.
  int i=0;
  if (i) {
  System.out.println(“Hi”);
  }

  B.
  boolean b=true;
  boolean b2=true;
  if(b==b2) {
  System.out.println(“So true”);
  }

  C.
  int i=1;
  int j=2;
  if(i==1|| j==2)
  System.out.println(“OK”);

  D.
  int i=1;
  int j=2;
  if (i==1 &| j==2)
  System.out.println(“OK”);

  解答:B, C

  点评:选项A错,因为if语句后需要一个boolean类型的表达式。逻辑操作有^、&、| 和 &&、||,但是“&|”是非法的,所以选项D不正确。

  例题5:

  Which two demonstrate a "has a" relationship? (Choose two)

  A. public interface Person { }
  public class Employee extends Person{ }

  B. public interface Shape { }
  public interface Rectandle extends Shape { }

  C. public interface Colorable { }
  public class Shape implements Colorable
  { }

  D. public class Species{ }
  public class Animal{private Species species;}

  E. interface Component{ }
  class Container implements Component{
  private Component[] children;
  }

  解答:D, E

  点评: 在Java中代码重用有两种可能的方式,即组合(“has a”关系)和继承(“is a”关系)。“has a”关系是通过定义类的属性的方式实现的;而“is a”关系是通过类继承实现的。本例中选项A、B、C体现了“is a”关系;选项D、E体现了“has a”关系。

  例题6:

  Which two statements are true for the class java.util.TreeSet? (Choose two)
  
  A. The elements in the collection are ordered.

  B. The collection is guaranteed to be immutable.

  C. The elements in the collection are guaranteed to be unique.

  D. The elements in the collection are accessed using a unique key.
  E. The elements in the collection are guaranteed to be synchronized
  解答:A, C

  点评:TreeSet类实现了Set接口。Set的特点是其中的元素惟一,选项C正确。由于采用了树形存储方式,将元素有序地组织起来,所以选项A也正确。


例题7:

  True or False: Readers have methods that can read and return floats and doubles.

  A. Ture

  B. False

  解答:B

  点评: Reader/Writer只处理Unicode字符的输入输出。float和double可以通过stream进行I/O.

  例题8:

  What does the following paint() method draw?

  1. public void paint(Graphics g) {

  2. g.drawString(“Any question”, 10, 0);

  3. }

  A. The string “Any question?”, with its top-left corner at 10,0

  B. A little squiggle coming down from the top of the component.

  解答:B

  点评:drawString(String str, int x, int y)方法是使用当前的颜色和字符,将str的内容显示出来,并且最左的字符的基线从(x,y)开始。在本题中,y=0,所以基线位于最顶端。我们只能看到下行字母的一部分,即字母‘y’、‘q’的下半部分。

  例题9:

  What happens when you try to compile and run the following application? Choose all correct options.

  1. public class Z {

  2. public static void main(String[] args) {

  3. new Z();

  4. }

  5.

  6. Z() {

  7. Z alias1 = this;

  8. Z alias2 = this;

  9. synchronized(alias1) {

  10. try {

  11. alias2.wait();

  12. System.out.println(“DONE WAITING”);

  13. }
 
  14. catch (InterruptedException e) {

  15. System.out.println(“INTERR
  UPTED”);

  16. }

  17. catch (Exception e) {
 
  18. System.out.println(“OTHER EXCEPTION”);

  19. }

  20. finally {

  21. System.out.println
  (“FINALLY”);

  22. }

  23. }

  24. System.out.println(“ALL DONE”);

  25. }

  26. }

  A. The application compiles but doesn't print anything.

  B. The application compiles and print “DONE WAITING”

  C. The application compiles and print “FINALLY”

  D. The application compiles and print “ALL DONE”

  E. The application compiles and print “INTERRUPTED”

  解答:A

  点评:在Java中,每一个对象都有锁。任何时候,该锁都至多由一个线程控制。由于alias1与alias2指向同一对象Z,在执行第11行前,线程拥有对象Z的锁。在执行完第11行以后,该线程释放了对象Z的锁,进入等待池。但此后没有线程调用对象Z的notify()和notifyAll()方法,所以该进程一直处于等待状态,没有输出。

  例题10:

  Which statement or statements are true about the code listed below? Choose three.

  1. public class MyTextArea extends TextArea {

  2. public MyTextArea(int nrows, int ncols) {

  3. enableEvents(AWTEvent.TEXT_
  EVENT_MASK);

  4. }

  5.

  6. public void processTextEvent
  (TextEvent te) {

  7. System.out.println(“Processing a text event.”);

  8. }

  9. }

  A. The source code must appear in a file called MyTextArea.java

  B. Between lines 2 and 3, a call should be made to super(nrows, ncols) so that the new component will have the correct size.

  C. At line 6, the return type of processTextEvent() should be declared boolean, not void.

  D. Between lines 7 and 8, the following code should appear: return true.

  E. Between lines 7 and 8, the following code should appear: super.processTextEvent(te).

  解答:A, B, E

  点评:由于类是public,所以文件名必须与之对应,选项A正确。如果不在2、3行之间加上super(nrows,ncols)的话,则会调用无参数构建器TextArea(), 使nrows、ncols信息丢失,故选项B正确。在Java2中,所有的事件处理方法都不返回值,选项C、D错误。选项E正确,因为如果不加super.processTextEvent(te),注册的listener将不会被唤醒。

1.Which statement about the garbage collection mechanism are true?
  A. Garbage collection require additional programe code in cases where multiple  threads are running.
  B. The programmer can indicate that a reference through a local variable is no longer of interest.
  C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.
  D. The garbage collection mechanism can free the memory used by Java Object at explection time.
  E. The garbage collection system never reclaims memory from objects while are still accessible to running user threads.

1。B、E
  JAVA的垃圾回收机制是通过一个后台系统级线程对内存分配情况进行跟踪实现的,对程序员来说是透明的,程序员没有任何方式使无用内存显示的、立即的被释放。而且它是在程序运行期间发生的。
  答案B告诉我们程序员可以使一个本地变量失去任何意义,例如给本地变量赋值为“null”;答案E告诉我们在程序运行期间不可能完全释放内存。


  2. Give the following method:
  1) public void method( ){
  2) String a,b;
  3) a=new String(“hello world”);
  4) b=new String(“game over”);
  5) System.out.println(a+b+”ok”);
  6) a=null;
  7) a=b;
  8) System.out.println(a);
  9) }
  In the absence of compiler optimization, which is the earliest point the object   a refered is definitely elibile to be garbage collection.
  A. before line 3
  B.before line 5
  C. before line 6
  D.before line 7
  E. Before line 9

2。D
  第6行将null赋值给a以后,a以前保存的引用所指向的内存空间就失去了作用,它可能被释放。所以对象a可能最早被垃圾回收是在第7行以前,故选择D选项。

  3. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method called getID which phrase accurately describes the return value of this method?
  A. It is a reference to the object directly affected by the cause of the event.
  B. It is an indication of the nature of the cause of the event.
  C. It is an indication of the position of the mouse when it caused the event.
  D. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event.
  E. It tells the state of certain keys on the keybord at the time of the event.
  F. It is an indication of the time at which the event occurred.

3。B
  请查阅JAVA类库。getID方法的返回值是“event type”。在认证考试中,总会有类似的书本以外的知识,这只能靠多实践来增长知识了。

4. Which statement about listener is true?
  A. Most component allow multiple listeners to be added.
  B. If multiple listener be add to a single component, the event only affected one listener.
  C. Component don?t allow multiple listeners to be add.
  D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.

4。A、D
  控件可以同时使用多个“addXxxxListener”方法加入多个监听器。并且当多个监听器加入到同一控件中时,事件可以响应多个监听器,响应是没有固定顺序的。


  5.Give the following code:
  public class Example{
  public static void main(String args[] ){
  int l=0;
  do{
  System.out.println(“Doing it for l is:”+l);
  }while(--l>0)
  System.out.println(“Finish”);
  }
  }
  Which well be output:
  A. Doing it for l is 3
  B. Doing it for l is 1
  C. Doing it for l is 2
  D. Doing it for l is 0
  E. Doing it for l is ?C1
  F. Finish

5。D、F
  本题主要考察考生对流程控制的掌握情况。这是当型循环,条件为真执行,条件为假则退出。循环体至少执行一次,故会输出D。循环体以外的语句总会被执行,故输出F。
6. Give the code fragment:
  1) switch(x){
  2) case 1:System.out.println(“Test 1”);break;
  3) case 2:
  4) case 3:System.out.println(“Test 2”);break;
  5) default:System.out.println(“end”);
  6) }
  which value of x would cause “Test 2” to the output:
  A. 1
  B. 2
  C. 3
  D. default

6。B.C
  在开关语句中,标号总是不被当做语句的一部分,标号的作用就是做为条件判断而已,一旦匹配成功,就执行其后的语句,一直遭遇break语句为止。(包括default语句在内)
7. Give incompleted method:
  1)
  2) { if(unsafe()){//do something…}
  3) else if(safe()){//do the other…}
  4) }
  The method unsafe() well throe an IOException, which completes the method of declaration when added at line one?
  A. public IOException methodName()
  B. public void methodName()
  C. public void methodName() throw IOException
  D. public void methodName() throws IOException
  E. public void methodName() throws Exception
7。D、F
  IOException异常类是Exception的子类。根据多态性的定义,IOException对象也可以被认为是Exception类型。还要注意在方法声明中抛出异常应用关键字“throws”。
8. Give the code fragment:
  if(x>4){
  System.out.println(“Test 1”);}
  else if (x>9){
  System.out.println(“Test 2”);}
  else {
  System.out.println(“Test 3”);}
  Which range of value x would produce of output “Test 2”?
  A. x<4>
  B. x>4
  C. x>9
  D. None

8。D
  只有两种情况:大于4时输出“Test1”,小于等于4时输出“Test3”。
9. Give the following method:
  public void example(){
  try{
  unsafe();
  System.out.println(“Test1”);
  }catch(SafeException e){System.out.println(“Test 2”);
  }finally{System.out.println(“Test 3”);}
  System.out.println(“Test 4”);
  Which will display if method unsafe () run normally?
  A. Test 1
  B. Test 2
  C. Test 3
  D. Test 4

9。A、C、D
  在正常情况下,打印Test1、Test3、Test4;在产生可捕获异常时打印Test2、Test3、Test4;在产生不可捕获异常时,打印Test3,然后终止程序。注意finally后面的语句总是被执行。
10. Which method you define as the starting point of new thread in a class from which new the thread can be excution?
  A. public void start()
  B. public void run()
  C. public void int()
  D. public static void main(String args[])
  E. public void runnable()

10。B
  线程的执行是从方法“run( )”开始的,该方法是由系统调用的。程序员手工调用方法start(),使线程变为可运行状态。
11.Given the following class definition:
  class A{
  protected int i;
  A(int i){
  this.i=i;
  }
  }
  which of the following would be a valid inner class for this class?
  Select all valid answers:
  A. class B{
  }
  B. class B extends A{
  }
  C. class B extends A{
  B(){System.out.println(“i=”+i);}
  }
  D. class B{
  class A{}
  }
  E. class A{}

11。A
  此题考查内部类及关键字“super”的用法。内部类不能与外部类同名。另外,当B继承A时,A中的构造函数是带参数的,B中缺省构造函数的函数体为空;而JAVA编译器会为空构造函数体自动添加语句“super();”调用父类构造函数,更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函数。
12. Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body?
  A. synchronized
  B. abstract
  C. final
  D. static
  E. public

12。A
  此关键字可以在两个线程同时试图访问某一数据时避免数据毁损。
13. The following code is entire contents of a file called Example.java,causes precisely one error during compilation:
  1) class SubClass extends BaseClass{
  2) }
  3) class BaseClass(){
  4) String str;
  5) public BaseClass(){
  6) System.out.println(“ok”);}
  7) public BaseClass(String s){
  8) str=s;}}
  9) public class Example{
  10) public void method(){
  11) SubClass s=new SubClass(“hello”);
  12) BaseClass b=new BaseClass(“world”);
  13) }
  14) }

  Which line would be cause the error?
  A. 9 B. 10 C. 11 D.12

13。C
  当一个类中未显式定义构造函数时,缺省的构造函数是以类名为函数名,参数为空,函数体为空。虽然父类中的某一构造函数有字符串参数s,但是子类继承父类时并不继承构造函数,所以它只能使用缺省构造函数。故在第11行出错。

14. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?
  A. String [] a
  B. String a[]
  C. char a[][]
  D. String a[50]
  F. Object a[50]

14。A、B
  注意,题中问的是如何正确声明一个一维数组,并非实例化或者初始化数组
15. Give the following java source fragement:
  //point x
  public class Interesting{
  //do something
  }
  Which statement is correctly Java syntax at point x?
  A. import java.awt.*;
  B.package mypackage
  C. static int PI=3.14
  D. public class MyClass{//do other thing…} E. class MyClass{//do something…}

15。A、E
  X处可以是一个输入,包的定义,类的定义。由于常量或变量的声明只能在类中或方法中,故不能选择C;由于在一个文件中只能有一个public类,故不能选择D。
16. Give this class outline:
  class Example{
  private int x;
  //rest of class body…
  }
  Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?
  A. Change private int x to public int x
  B. change private int x to static int x
  C. Change private int x to protected int x
  D. change private int x to final int x

16。B
  静态方法除了自己的参数外只能直接访问静态成员。访问非静态成员,必须先实例化本类的一个实例,再用实例名点取。
17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project
“The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.”
Which Data type would be used?
  A. Vector
  B. int
  C. String
  D. Color
  E. Date

17。A、B、D
  polygon的顶点信息存放在Vector类型的对象内部,color定义为Color,length和width定义为int。
  注意,这是考试中常见的题型。
18. A class design requires that a member variable should be accessible only by same package, which modifer word should be used?
  A. protected
  B. public
  C. no modifer
  D. private
18。C
  此题考点是高级访问控制。请考生查阅高级访问控制说明表格。
19.Which declares for native method in a java class corrected?
  A. public native void method(){}
  B. public native void method();
  C. public native method();
  D. public void method(){native;}
  E. public void native method();

19。B
  native关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。
20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?

20。final
  定义常量的方法是在变量定义前加final关键字。
21. Which is the main() method return of a application?
  A. String
  B. byte
  C. char
  D. void


21。D
  main()方法没有返回值,所以必须用void修饰。main()方法的返回值不能任意修改。
22. Which is corrected argument of main() method of application?
  A. String args
  B. String ar[]
  C. Char args[][]
  D. StringBuffer arg[]

22。B
  main()方法的参数是字符串数组,参数名可以任意定义。
23. “The Employee object is a person, An Employee has appointment store in a    vector, a hire date and a number of dependent”
  short answer: use shortest statement declare a class of Employee.

23。public class Employee extends Person
  这也是真实考试中常见的一种题型。要注意题目叙述中“is a”表示 “extends”的含义。

24. Give the following class defination inseparate source files:
  public class Example{
  public Example(){//do something}
  protected Example(int i){//do something}
  protected void method(){//do something}
  }
  public class Hello extends Example{//member method and member variable}
  Which methods are corrected added to the class Hello?
  A. public void Example(){}
  B. public void method(){}
  C. protected void method(){}
  D. private void method(){}

24。A、B、C
  考察的知识点是方法覆盖,其中要注意的是方法覆盖时,子类方法的访问权限不能小于父类方法的访问权限。另外,选项A并不是父类构造函数,它是子类中的新方法。
25. Float s=new Float(0.9F);
  Float t=new Float(0.9F);
  Double u=new Double(0.9);
  Which expression?s result is true?
  A. s==t
  B. s.equals(t)
  C. s==u
  D. t.equals(u)
25。A、B
  考察“==”及方法“equals()”的用法。注意以下几点区别:
  1) 引用类型比较引用;基本类型比较值。
  2) equals()方法只能比较引用类型,“==”可比较引用及基本类型。
  3) 当用equals()方法进行比较时,对类File、String、Date及封装类(Wrapper Class)来说,是比较类型及内容。
  4) 用“==”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错。
分享到:
评论
1 楼 yuniannian 2010-03-16  

相关推荐

    华为英语面试题汇总英文面试 外企互联网面试英文题准备资料汇总.zip

    华为面试,英文英语部分准备;...英语面试题(各外企JAVA等岗位英文面试题汇总-100问);最新的英语笔试题目及参考答案;最新整理华为面试英语测试常见问题。资料同时适用于外企招聘,外企互联网招聘,微软中国等。

    英语面试题(各外企JAVA等岗位英文面试题汇总-100问).rtf

    华为英语面试题汇总英文面试外企互联网面试英文题准备,华为OD,华为软件工程师,开发工程师面试准备,英文面试题参考资料。

    java技术英文面试题

    Java 技术英文面试题 Java 技术英文面试题是 Java 开发者面试中常见的问题,这些问题涵盖了 Java 的多个方面,包括容器、多线程、集合 API 等。 容器和布局管理 在 Java 中,容器是指可以包含其他组件的组件,...

    Java英语面试题

    ### Java英语面试题详解 #### 1. 什么是瞬态变量? 在Java中,瞬态(transient)变量是一个特殊类型的变量,它被用于标记一个类中的某个成员变量,表明这个变量不应该被序列化。当一个对象被写入到一个`...

    IBM英文面试题及答案

    IBM英文面试题及答案,希望能给大家带来好运

    java英语面试题

    ### Java 英语面试题详解 #### 多态性(Polymorphism) 多态性是面向对象编程的一个核心概念,其基本含义为“一个接口多种实现”。在 Java 中,多态性主要体现在以下两个方面: - **方法重载(Method Overloading...

    教师资格证小学英语面试真题.doc

    教师资格证小学英语面试真题.doc

    Java_英文面试题_经典

    Java编程语言在面试中常常涉及一系列的关键概念和技术,这些在提供的英文面试题中有所体现。以下是对这些面试问题的详细解答: 1. **什么是transient变量?** `transient`关键字在Java中用于标记一个字段,表示这...

    嵌入式工程师英文面试题及解答

    "嵌入式工程师英文面试题及解答" 根据提供的文件信息,我们可以总结出以下知识点: 1. 变量的存储位置 在 C 语言中,变量的存储位置取决于其生命期和作用域。局部变量存储在栈(Stack)中, globals 和静态变量...

    Java_英文面试题

    Java编程语言在面试中常常涉及各种技术点,包括序列化、布局管理器、同步机制、集合API、迭代器以及抽象类与接口的区别等。以下是对这些知识点的详细解释: 1. **临时变量(Transient Variable)**: - `transient...

    java英文面试题

    Java编程语言在面试中是常考的科目,尤其对于国际化的工作环境,掌握一定的英文编程基础是必不可少的。以下是一些常见的Java面试英文题目的解析: 1. 哪些行可以无警告或错误地编译? 答案:5) int i=10; 解析:...

    中兴最新面试含英语面试试题,答案,高级介绍

    含英语面试试题,答案,高级介绍 中兴最新面试

    .NET/C# 英文面试题[附答案]汇总 2

    以上就是一些关于.NET/C#英文面试中常见的知识点,涵盖了类继承、访问修饰符、接口、抽象类与方法、委托、事件、异常处理、泛型、属性以及异步编程等多个方面。了解并掌握这些概念对于成为一名合格的.NET开发者至关...

    企业公司软件测试面试笔试题集合 软件测试面试题

    企业公司软件测试面试笔试题集合 软件测试面试题 (测试基础).doc 01_企业面试试卷(综合).doc 01_企业面试试卷(综合)_参考答案.doc ...英语面试题.doc 有意思的逻辑题.doc 中软的面试题(转贴).doc

    .NET/C# 英文面试题[附答案]汇总 1

    .NET/C# 英文面试题及答案汇总 在.NET/C# 的面试中,掌握核心概念和技术是至关重要的。以下是一些常见的面试问题及其详细解答: 1. **ref 和 out 参数的区别是什么?** - `out` 参数:传递给 `out` 参数的变量...

    c#英文面试试题(等答案)

    C# 英文面试试题(含答案) C# 英文面试试题(含答案)是 C# 入门经典第三版面试试题,涵盖了 C# 语言的各个方面,包括基本语法、数据类型、运算符、控制流程、函数、数组、字符串、异常处理、oop、delegate、事件...

    java英语面试题汇总

    在Java软件开发领域,英语面试是评估候选人技术能力、沟通技巧以及压力处理能力的重要环节。以下是一些常见的Java英语面试问题及解析: 1. **自我介绍** 面试官可能会让你简单介绍一下自己,包括教育背景、工作...

    最新软件测试英文面试题

    我现在外企做软件测试工作月薪11K,不算最多也算中上了,就是这份英文面试题帮了我,希望对你们能有所帮助,祝看过这个文档的人也能入职外企,祝你们好运

    海信最新一面面经(英语面试题)

    海信最新一面面经(英语面试题),希望对各位有所帮助,谢谢大家。祝面试顺利!

    .net 面试题系列(网上收集)很全

    2008/01/19 20:25 9,674 Dot.NET-C#-VB.NET-ASP.NET 英文面试题(附答案).txt 2008/01/07 10:45 38,912 NET程序员面试题汇总.doc 2008/06/17 18:48 1,038 两个月薪上万的.Net面试题.txt 2008/06/26 21:19 7,321 ...

Global site tag (gtag.js) - Google Analytics