HOME      BLOG       FORUMS      CONTACT       ABOUT

Core Java interview questions – Part 9

136. Why Java is not 100% pure object oriented language?
Because java uses primitives.

137. Why ArrayList is faster than Vector?
Because Vector is synchronized. Synchronization reduces the performance.

138. What is the security mechanism used in java?
Java uses sand box security model.

139. 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. What is phantom memory?
Phantom memory is the memory that does not exist in reality.

141. What is reflection?
Reflection is the process of finding out the different features of a class dynamically.

142. 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 compiler, 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. 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 decrement the reference count each time. Because of these disadvantages, reference counting currently is out of favor.

144. 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. 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.

156. What is JAR file?
A JAR file (short for Java Archive) is a ZIP file used to distribute a set of Java classes. It is used to store compiled Java classes and associated meta data that can constitute a program

147. What is a classloader?
A class loader is an object that is responsible for loading classes.

148. 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. 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. What is the difference between Exception and Error ?
Error is unrecoverable.


Tags: , , ,

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply