Posts

Showing posts with the label Interview

Java J2EE Interview Questions For Experienced Set 1

Image
In my previous post, I have listed top 20 Exception handling interview questions here and 15 core java written interview questions for product based companies. Today, I have decided to post java,j2ee interview questions in different sets and each set will contain exactly 10 questions, which is similar to real time interview questions. The questions are based on real time interview experienced, and its for java,j2ee interview, that means combination of core java+hibernate+spring+algorithm+Design pattern etc. all about the real time interview question and based on real time pattern. If you are going for java,j2ee profile with Spring+Hibernate+Web Service than this set of questions is all yours. 1. Brief down your role and responsibilities, and what type of project you are working on. Interviewer start looking into your resume and asked this questions,This is very first question you will faced in any interview, and its your job to tell about your role(s) and designation in your curr...

What is the use of serialVersionUID in serialization in java

Image
Last updated: September 2026 — refreshed with modern Java notes and interview Q&A. In java all the Serializable classes are automatically given a unique identifier if you explicitly not defined. The unique identifier of the class is maintained by serialVersionUID field. So the serialVersionUID is a unique identifier of the serializable classes, and the value of serialVersionUID is used at the time of de-serialization to verify that the sender and receiver of a serialized object have loaded a class for that object that are compatible with respect to serialization. The default value of serialVersionUID is computed based on your class's field, method, interfaces etc. It may be vary from environment to environment or compiler to compiler. That's why you always need to define explicitly the value of serialVersionUID. It's better to redefine the value of serialVersionUID each time you changed the structure of your class. Syntax to define serialVersionUID: ANY-ACCESS-M...

Serializable vs Externalizable in Java Serialization

Last updated: September 2026 — rewritten with a comparison table, code examples, and interview Q&A. "Serializable vs Externalizable" is a favorite second-round interview question, especially for 3–5 year experienced roles. The interviewer isn't testing whether you've memorized two interfaces — they're testing whether you understand who controls the byte format and what that costs. If you haven't read the basics yet, start with what serialization is . Serializable vs Externalizable: the differences Feature Serializable Externalizable Interface type Marker interface — no methods Two methods: writeExternal() , readExternal() Who controls the format The JVM (default protocol) You (custom protocol) Effort Zero — just implement the interface You hand-write the field logic Constructor on deserialization Not called Public no-arg constructor is called (mandatory) Performance Slower — uses reflection Faster — direct method calls, smaller streams Custo...

What are the methods of Object class in java?

This question is most respected java interview question and always on demand, before going to advance concept smart interviewer wants to check your fundamental concept regarding java. Interviewer ask you to list down all the method of Object class or list down all the public non final methods of Object class, once you listed he/she will start asking about why they are in object class and when to use them? Well in java Object class is a super class of all the classes available in java including your own classes and resides inside java.lang package. All classes including your own custom classes inherit the instance methods of Object class and those methods are listed below. type javap java.lang.Object on command prompt to list all the methods of Object class. Here we listed all the methods of java.lang.Object class public String toString() public final native Class getClass() public native int hashCode() public boolean equals(java.lang.Object) protected void finalize() thro...

What is marker interface in java

This types of questions mostly asked for fresher level or 2-3 years of experienced candidates only. Marker interface in java is an empty interface and used to define type of the class. Serializable is a marker interface whenever a class implements a marker interface that class got a special treatment via special methods of java library. For example, If a class implements Serializable interface and going to be serialized then writeObject(obj) method of ObjectOutputStream class does the validation check for the object with the help of instanceof of operator. If object is an instanceof Serializable then write as ordinary object otherwise throw NotSerializableException exception. There is no magic inside the JVM for the Serializable it's all about the writeObject(obj) method who take cares of Serializable object. Here is how serializable interface used inside writeObject(obj) method: if (obj instanceof Serializable) { writeOrdinaryObject(obj, desc, unshared); } In a nu...

Why equals() method in java?

This is again a very common interview question to check the basic concepts of java. Object is super class of all the classes in java and equals() method is exist inside this class. Well, The equals() method as it's name implies this method is used to check the equality of the objects and you know the equality is possible only with more than one objects. So the same way, equals() method of Object class is used to check whether "this object" is equal to "other object ". For example whether the soccer balls was used in FIFA 2014 World Cup are equal to the soccer balls was used in FIFA 2010 World Cup. Definitely answer will be based on the comparison of the specifications used in both the soccer balls example, what are the Circumference, Diameter, Weight, Loss of pressure etc. But if question is something like In which FIFA World cup maximum soccer ball was consumed? 2010 or 2014. Answer will be based on comparison of number of soccer balls was used in both the...

How many ways to create object in java

Basic Java interview question, This types of questions mostly asked at fresher or very less experienced level. If you are thinking about to jump inside the world of Java or you have 2-3 years of experience in java. Then you must have to know the answer of this question, and what are the ways to create an object in java. Well Technically 5 ways to create an object in java: 1. new keyword. Using new keyword, which is very common approach to create an object. 2. Reflection (Class.forName().newInstance() method). Using reflection api. with the help of Class.forName("class") load the class and then newInstance() method to create an object. 3. With the help of class loader. Using getClassLoader().load() method which will again load the class and then call newInstance() method to create an object. clone() If your class implements Cloneable interface then use clone() method to create an object. Note: clone() method will never call your constructor to create an o...

What are the core classes and interfaces of hibernate 4

Hibernate is an Open source Object Relational Mapping framework. It enables developer to develop classes to be persist in an object oriented way including inheritance and the Java collections framework. Current hibernate stable release is 4.3.5 that was released in April 2014. It has various classes and interfaces, but sometimes interviewer ask you to list down the core classes and interfaces of hibernate. Well hibernate has various classes and interfaces, but when we say core classes and interfaces those are listed below, they all are the exceptional role in hibernate library. Configuration (class) ServiceRegistry (interface) SessionFactory (interface) Session (interface) Transaction (interface) Query (interface) Configuration: Is a class resides inside the org.hibernate.cfg package. Configuration as it's name implies it is all about the configuration of the application, configuration of the application done only at the initialization time which is only once for t...

Why getClass() method in java

getClass(): getClass method of java.lang.Object class is a final method means you cannot override the getClass method. Sometimes interviewer ask you to override the getClass method just to confuse you. But don't be confused all the method of Object class cannot be override except toString(),equals(Object o),hashCode(),clone() and finalize() once again getClass() is a final method of Object class and you cannot override the final methods . getClass method return the runtime class of the object which has method called. By using getClass method you will get the full information about the class such as number of methods in your class declared using getClass().getMethods() which will return you the array of methods, number of interfaces implemented by your class using getClass().getInterfaces() In nutshell you will get the whole information about your class using getClass() method. For example the below class is going to display you the number of methods,fields declared in Product...

How toString method works in java? why we need to always override toString()

First lets see how the toString method work internally, then we move why always override the toString method. toString() method return String representation of the object,default implementation of the toString method in Object class is public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); } The return string of the toString() is fully qualified name of the class which the object is an instance, concatenating with @ symbol and hex string of the hash code return by the hashCode() method. For example: Product.java package com.javamakeuse.test; public class Product { private String name; private double price; private String manufacturer; public String getName() { return name; } public void setName(String name) { this.name = name; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getManufacturer() { return manufacturer; } ...