Posts

Showing posts from February, 2015

Java Interview Questions - Pramathi Technologies

Below questions asked in Pramathi Technologies telephonic interview - JAVA 4 years exp: 1.  What is heap dump?  A JVM heap dump is basically a  "snapshot"  of the Java heap memory at a given time.  It is quite different than a JVM thread dump which is a snapshot of the threads.  It is particularly useful when troubleshooting Java heap memory leaks and  java.lang.OutOfMemoryError  problems.  " JVM heap dump generation is an intrusive process which will hang your JVM process until completion " more details...

Java Interview Questions - NTT DATA

Below questions asked in NTT DATA telephonic interview - JAVA 4 years exp: How to make a class as immutable ?  Why String class is immutable ? What is the difference between abstract class and interface ? When to use abstract class and interface ? What is the difference between collections.synchronizedmap and concurrenthashmap ? What is the countdownlatch and cyclicbarrier ? What is the difference between wait() and sleep() ? What happens if an object is serializable but it includes a reference to a non-serializable object? What is synchronization ? What is SQL injection ? How HashMap works internally?

Java Interview Questions - Serialization

Image
1. What is serialization in java ? Object Serialization in Java is a process used to convert Object into a binary format which can be persisted into disk or sent over network to any other running java virtual machine. The reverse process of creating object from binary stream is called deserialization in Java. Java provides Serialization API for serializing and deserializing object which includes java.io.Serializable , java.io.Externalizable , ObjectInputStream and ObjectOutputStream etc.  2. What is the need of Serialization? To send state of one or more object’s state over the network through a socket. To save the state of an object in a file. An object’s state needs to be manipulated as a stream of bytes. 3. Do we need to implement any method of Serializable interface to make an object serializable? No. Serializable is a Marker Interface. It does not have any methods. 4. How would you exclude a field of a class from serialization or what is a tr...

Java Interview Questions - Immutability

1. What is an immutable class? Immutable class is a class which once created, it’s contents can not be changed. Immutable  objects are the objects whose state can not be changed once constructed. e.g. String class 2. How to create an immutable class? To create an immutable class following steps should be followed: Create a final class. Set the values of properties using constructor only. Make the properties of the class final and private Do not provide any setters for these properties. If the instance fields include references to mutable objects, don't allow those objects to be changed: Don't provide methods that modify the mutable objects. Don't share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store references to the copies. Similarly, create copies of your internal mutable objects when necessary to avoid returning the originals in your methods. ...