java面试题和答案(英文版)

上传人:第*** 文档编号:57489552 上传时间:2018-10-22 格式:PDF 页数:14 大小:114.78KB
返回 下载 相关 举报
java面试题和答案(英文版)_第1页
第1页 / 共14页
java面试题和答案(英文版)_第2页
第2页 / 共14页
java面试题和答案(英文版)_第3页
第3页 / 共14页
java面试题和答案(英文版)_第4页
第4页 / 共14页
java面试题和答案(英文版)_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《java面试题和答案(英文版)》由会员分享,可在线阅读,更多相关《java面试题和答案(英文版)(14页珍藏版)》请在金锄头文库上搜索。

1、Java 面试题和答案(英文版)Q: What is the difference between an Interface and an Abstract class?A: An abstract class can have instance methods that implement a default behavior. An Interface can onlydeclare constants and instance methods, but cannot implement default behavior and all methods are implicitlyabst

2、ract. An interface has all public members and no implementation. An abstract class is a class which mayhave the usual flavors of class members (private, protected, etc.), but has some abstract methods.Q: What is the purpose of garbage collection in Java, and when is it used?A: The purpose of garbage

3、 collection is to identify and discard objects that are no longer needed by a programso that their resources can be reclaimed and reused. A Java object is subject to garbage collection when itbecomes unreachable to the program in which it is used.Q: Describe synchronization in respect to multithread

4、ing.A: With respect to multithreading, synchronization is the capability to control the access of multiple threads toshared resources. Without synchonization, it is possible for one thread to modify a shared variable while anotherthread is in the process of using or updating same shared variable. Th

5、is usually leads to significant errors.Q: Explain different way of using thread?A: The thread could be implemented by using runnable interface or by inheriting from the Thread class. Theformer is more advantageous, cause when you are going for multiple inheritancethe only interface can help.Q: What

6、are pass by reference and passby value?A: Pass By Reference means the passing the address itself rather than passing the value. Passby Value meanspassing a copy of the value to be passed.Q: What is HashMap and Map?A: Map is Interface and Hashmap is class that implements that.Q: Difference between Ha

7、shMap and HashTable?A: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.(HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guaranteethat the order of the map will remain constant over time. HashMap is

8、 unsynchronized and Hashtable issynchronized.Q: Difference between Vector and ArrayList?A: Vector is synchronized whereas arraylist is not.Q: Difference between Swing and Awt?A: AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster thanAWT.Q: What is the diff

9、erence between a constructor and a method?A: A constructor is a member function of a class that is used to create objects of that class. It has the same nameas the class itself, has no return type, and is invoked using the new operator.A method is an ordinary member function of a class. It has its o

10、wn name, a return type (which may be void), andis invoked using the dot operator.Q: What is an Iterator?A: Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. Thisinterface allows you to walk through a collection of objects, operating on each object

11、 in turn. Remember whenusing Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally itis not advisable to modify the collection itself while traversing an Iterator.Q: State the significance of public, private, protected, default modifiers both singl

12、y and in combination and statethe effect of package relationships on declared items qualified by these modifiers.A: public : Public class is visible in other packages, field is visible everywhere (class must be public too)private : Private variables or methods may be used only by an instance of the

13、same class that declares thevariable or method, A private feature may only be accessed by the class that owns the feature.protected : Is available to all classes in the same package and also available to all subclasses of the class thatowns the protected feature.This access is provided even to subcl

14、asses that reside in a different package fromthe class that owns the protected feature.default :What you get by default ie, without any access modifier (ie, public private or protected).It means thatit is visible to all within a particular package.Q: What is an abstract class?A: Abstract class must

15、be extended/subclassed (to be useful). It serves as a template. A class that is abstractmay not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any classwith an abstract method is automatically abstract itself, and must be declared as such.A class may

16、be declared abstract even if it has no abstract methods. This prevents it from being instantiated.Q: What is static in java?A: Static means one per class, not one for each object no matter how many instance of a class might exist. Thismeans that you can use them without creating an instance of a class.Static methods are implicitly final, becauseoverriding is done based on the type of the object, and static methods are attached to a class, not an object. Astatic method in a superclass can be sha

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 事务文书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号