132 Q What is volatile variable?
A volatile variable is not allowed to have a local copy of a variable that is different from the value currently held in "main" memory. Volatile modifier requests the JVM to always access the shared copy of the variable so the its most current value is always read.
133 Q Why java does not multiple inheritance?
Because the multiple inheritance causes the redundancy. Also we cannot solve diamond problem.
134 Q What is diamond problem?
The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class
135 Q How many JVM's we can run in a system?
Any number of JVMs can run in a system. Whenever we issue the command 'java' a new JVM will start.
Because java uses primitives.
137 Q Why ArrayList is faster than Vector?
Because Vector is synchronized. Synchronization reduces the .
138 Q What is the mechnaism used in java?
Java uses sand box security model.
139 Q What is sandbox?
A sandbox is a security mechanism for safely running programs. The sandbox typically provides a tightly-controlled set of resources for guest programs to run in, such as scratch space on disk and memory.
140 Q What is phantom memory?
Phantom memory is the memory that does not exist in reality.
141 Q What is reflection?
Reflection is the process of finding out the different features of a class dynamically.
142 Q What are the differences between JIT and HotSpot?
The Hotspot VM is a collection of techniques, the most important of which is called adaptive optimization. The original JVMs interpreted byte codes one at a time. Second-generation JVMs added a JIT , which compiles each method to native code upon first execution, then executes the native code. Thereafter, whenever the method is called, the native code is executed. The adaptive optimization technique used by Hotspot is a hybrid approach, one that combines byte code interpretation and run-time compilation to native code. Hotspot, unlike a regular JIT compiling VM, doesn't do "premature optimization"
143 Q What are the advantages and disadvantages of reference counting in garbage collection?
An advantage of this scheme is that it can run in small chunks of time closely linked with the execution of the program. These characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very long time. A disadvantage of reference counting is that it does not detect cycles. A cycle is two or more objects that refer to one another. Another disadvantage is the overhead of incrementing and decrementing the reference count each time. Because of these disadvantages, reference counting currently is out of favor.
144 Q How would you implement a thread pool?
The ThreadPool class is a generic implementation of a thread pool, which takes the following input Size of the pool to be constructed and name of the class which implements Runnable (which has a visible default constructor) and constructs a thread pool with active threads that are waiting for activation. once the threads have finished processing they come back and wait once again in the pool.
145 Q What is the difference between throw and throws clause?
throw is used to throw an exception manually, where as throws is used in the case of checked exceptions, to tell the compiler that we haven't handled the exception, so that the exception will be handled by the calling function.
146 Q What is JAR file?
147 Q What is a classloader?
A class loader is an object that is responsible for loading classes.
148 Q What is the difference between Comparable and Comparator ?
The Comparable is for natural ordering and Comparator is for custom ordering. But we can override the compareTo method of comparable interface to give a custom ordering.
149 Q What is the difference between List, Set and Map?
A Set is a collection that has no duplicate elements. A List is a collection that has an order associated with its elements. A map is a way of storing key/value pairs. The way of storing a Map is similar to two-column table.
150 Q What is the difference between Exception and Error ?
Error is unrecoverable.