我在这里: 首页 ? 面试试题 ? 浏览文章: 30道英文Java面试题附英文答案(16-30)
« 英语面试题汇总二SQL Server面试题(更改帐户,链接Oracle) »

30道英文Java面试题附英文答案(16-30)




内容摘要:本文是本站从国外知名的java技术网站搜来的,为即将参加IT外企的java软件工程师面试的开发人员精心准备的。软件开发行业的外企面试一般都是全英文哦(技术面试和非技术面试)。
关键词:JAVA面试题  
本文地址:http://www.teecool.com/post/2007102601.html
内容正文:

* Q16. Can an inner class declared inside of a method access local variables of this method?

A. It's possible if these variables are final.
* Q17. What can go wrong if you replace && with & in the following code:


String a=null; if (a!=null && a.length()>10) {...}


A. A single ampersand here would lead to a NullPointerException.

* Q18. What's the main difference between a Vector and an ArrayList

A. Java Vector class is internally synchronized and ArrayList is not.

* Q19. When should the method invokeLater()be used?

A. This method is used to ensure that Swing components are updated through the event-dispatching thread.


* Q20. How can a subclass call a method or a constructor defined in a superclass?

A. Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.
For senior-level developers:

** Q21. What's the difference between a queue and a stack?

A. Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule
 
** Q22. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

A. Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.
 
** Q23. What comes to mind when you hear about a young generation in Java?

A. Garbage collection.
 
** Q24. What comes to mind when someone mentions a shallow copy in Java?

A. Object cloning.
 
** Q25. If you're overriding the method equals() of an object, which other method you might also consider?

A. hashCode()
 
** Q26. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use:
ArrayList or LinkedList?

A. ArrayList
 
** Q27. How would you make a copy of an entire Java object with its state?

A. Have this class implement Cloneable interface and call its method clone().
 
** Q28. How can you minimize the need of garbage collection and make the memory use more effective?

A. Use object pooling and weak object references.
 
 ** Q29. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

A. If these classes are threads I'd consider notify() or notifyAll(). For regular classes you can use the Observer interface.
 
** Q30. What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?

A. You do not need to specify any access level, and Java will use a default package access level.


The J2EE questions are coming soon. Stay tuned for Yakov Fain on Live SYS-CON.TV. Ask your questions to Yakov on the air!

30道英文Java面试题附英文答案(16-30)一文有面试题库网收集自互联网,并非本站原创,如原作者发现30道英文Java面试题附英文答案(16-30)一文,请及时告知本站,本站会作出相关处理,谢谢!!!(联系方式:百度空间留言)

最近发表