-
What are immutable objects most useful in?
Concurrent applications -
How do you create a new class that maps keys to values using the Collections Framework?
Extend from AbstractMap to implement the Map interface -
Given:
public abstract class Animal{…}
public class Dog extends Animal{…}
What allows you to use a parent class reference to refer to a child class object? For example:
Animal animal = new Dog();
Polymorphism 多态 /,pɒlɪ’mɔːfɪz(ə)m/
-
What effect does declaring a method as final have?
The method cannot be overridden in subclasses. -
What does the Object.wait() method do?
Causes the current thread to wait -
How can you stop your class from being inherited by another class?
Declare the class as final. -
Between the following options, which is the most efficient way to concatenate a large number of strings in Java?
The append() method in the StringBuilder class. -
Which statement is true about destructors in Java?
They are indirectly interpreted as a method called finalize, called at the discretion of the garbage collector.
An abstract class can implement an interface without implementing any of its methods.
-
Which statement about abstract classes is true?
An abstract class can implement an interface without implementing any of its methods. -
Which statement is true about serialization?
When an object is serialized, it is converted into a byte stream. -
Which statement about static nested classes is true?
They cannot invoke non-static methods of its enclosing class. -
What does the synchronized keyword on a method do?
It uses the object’s intrinsic lock to prevent two threads from accessing any synchronized method of the object simultaneously. -
What is the class for mutable sequences of characters Java provides called?
StringBuffer
14.How do you convert an array of type Integer (Integer[]) to a List of type Integer (List)?
By using the static Arrays.asList method
-
What is a LinkedHashSet?
A hash set which preserves the order in which objects were inserted -
When is a method considered to be overloaded?
If it has multiple call signatures within the same class scope -
Which primitive type is unsigned?
char -
Which Map implementation is safe for modification in a multi-threaded program?
java.util.concurrent.ConcurrentHashMap