Question from Java
What is the final keyword denotes?
final keyword denotes that it is the final implementation for that method or variable or class. You cant override that method/variable/class any more.
What is the significance of ListIterator?
You can iterate back and forth.
What is the major difference between LinkedList and ArrayList?
Linked List are meant for sequential accessing. ArrayList are meant for random accessing.
What is nested class?
If all the methods of a inner class is static then it is a nested class.
What is inner class?
If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
What is composition?
Holding the reference of the other class within some other class is known as composition.
What is aggregation?
It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.
What are the methods in Object?
clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
Can you instantiate the Math class?
You cant instantiate the math class. All the methods in this class are static. And the constructor is not public.
What is singleton?
It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods }