- Vector is synchronized, ArrayList is not.
- Vector is having a constructor to specify the incremental capacity. But ArrayList don't have.
- By default Vector grows by 100% but ArrayList grows by 50% only.
Saturday, June 7, 2008
What is the difference between Vector and ArrayList ?
What is final ?
- A final is a keyword in java.
- If final keyword is applied to a variable, then the variable will become a constant.
- If final keyword is applied to method, sub classes cannot override the method.
- If final keyword is applied to a class we cannot extend from that class.
What are the different ways in which a thread can enter into waiting state?
There are three ways for a thread to enter into waiting state. By invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method.
What is static ?
static means one per class. static variables are created when the class loads. They are associated with the class. In order to access a static we don't need objects. We can directly access static methods and variable by calling classname.variablename.
What does wait method do ?
It causes current thread to wait until either another thread invokes notify or notifyAll method of the current object, or a specified amount of time has elapsed.
What is the difference between notify and notifyAll method ?
notify wakes up a single thread that is waiting for object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. notifyAll Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.
What is the difference between a continue statement and a break statement?
Break statement results in the immediate termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.
Subscribe to:
Posts (Atom)