Question-71. What is NullPointerException ?

Answer- A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

Question-72. When is ArrayStoreException thrown ?

Answer- When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown.

Question-73. When is ArithmeticException thrown ?

Answer- The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations.

Question-74. What is the difference between an Interface and Abstract Class ?

Answer- An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation.

Question-75. What is the difference between an error and an exception ?

Answer- An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist.

Question-76. What is dynamic binding(late binding) ?

Answer- Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.

Question-77. What are the advantages of ArrayLists over arrays ?

Answer- ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.

Question-78. Why deletion in LinkedList is faster than ArrayList ?

Answer- Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.

Question-79. How do you decide when to use ArrayList and LinkedList ?

Answer- If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used. If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used.

Question-80. What is dot operator ?

Answer- The dot operator(.) is used to access the instance variables and methods of class objects. It is also used to access classes and sub-packages from a package.