Core Java Interview Questions and Answers for Freshers

What is Polymorphism?

The Polymorphism can be referred as one name many forms. It is the ability of methods to behave differently, depending upon the object who is calling it. The key features of Polymorphism are :
1. Allows using one interface for multiple implementations.
2. Supports Method Overloading: Multiple methods with same name, but different formal argument.
3. Supports Method Overridden: Multiple methods have the same name, same return type, and same formal argument list.

Explain garbage collection.

The Java uses the garbage collection to free the memory. By cleaning those objects that are no longer reference by any of the program. Step involve in cleaning up the garbage collection :
Garbage Object Collection : First step is to collection and group all those object which are no more reference with any of the program. We can use the different methods to collect the garbage object like using runtime.gc() or system.gc().
Run Finalize method : To free up those object which is collected by the garbage collector java must execute the Finalize method to delete all those dynamically created object.

What is an immutable object?

An immutable object is one that we cannot change once it is created. Steps involved in creation of an immutable object are :
- Make all of its data fields private.
- Methods which can perform changes in any of the data fields after the construction of object must be avoided.

How are this() and super() used with constructors?

this() Constructors :
- It is used to pointing the current class instance.
- It can be used with variables or methods.
- It is used to call constructer of same class.
- Private variable cannot be accessed using this().

super() Constructer :
- It is used to call constructor of parent class.
- Must be the first statement in the body of constructor.
- Using this we can access private variables in the super class.

What are Access Specifiers available in Java?

Java offers four access specifiers, described below :

Public : Public classes, methods, and fields can be accessed by every class.

Protected : Protected methods and fields can only be accessed within the same class to which the methods and fields belong.

Default (no specifier) : When we do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs.

Private : Private methods and fields can only be accessed within the same class to which the methods and fields belong. Private methods and fields are not inherited by subclasses.

What is Constructor?

- A constructor is used to initialize a newly created object.
- It is called just after the memory is allocated for the object.
- It can be used to initialize the objects.
- It is not mandatory to write a constructor for the class.
- Name of constructor is same as the class name.
- They cannot be inherited.
- A constructor is invoked whenever an object of its associated class is created.

What are the List interface and its main implementation?

The List helps in collections of objects. Lists may contain duplicate elements. The main implementations of the List interface are as follows :
ArrayList : Resizable-array implementation of the List interface.
Vector : Synchronized resizable-array implementation of the List.
LinkedList : Doubly-linked list implementation of the List interface. Better performance than the ArrayList implementation when elements are inserted or deleted timely.

Explain the user defined Exceptions.

User Defined Exceptions are exceptions defined by the user for specific purposed. This allows custom exceptions to be generated and caught in the same way as normal exceptions. While defining a User Defined Exception, we need to take care of the following aspects :
- It should be extend from Exception class.
- Use toString() method to display information about the exception.

Describe life cycle of thread.

Threads follow the single flow of control. A thread is execution in a program. The life cycles of threads are listed below :

Newborn state : After the creations of Thread instance the thread is in this state but before the start() method invocation. Thread is considered not alive in this phase.
Runnable state : A thread starts its life from Runnable state. After the invoking of start() method thread enters Runnable state.
Running state : A thread first enters Runnable state.
Blocked state : A thread can enter in this state because of waiting the resources that are hold by another thread.
Dead state : A thread can be considered dead when its run() method completes. If any thread comes on this state that means it cannot ever run again.

What is an Applets?

Applets :
- These are small java programs.
- They can send from one computer to another computer over the internet using the Applet Viewer that supports java.
- Applets can run in a Web browser as it is a java program. It can be a fully functional Java application because it has the entire Java API at its disposal.
- Applets follow the security rules given by the Web browser.
- Applet security is also known as sandbox security.

What is the Set interface?

- A set interface is a collection of element which cannot be duplicated.
- The set interface contains methods inherited from the collection.
- It provides methods to access the elements of a finite mathematical set.
- Two Set objects are equal if they contain the same elements.
- It models the mathematical set abstraction.
1 2 3

Core Java Interview Questions and Answers for Experienced
Core Java Interview Q & A for experienced - Why we prefer event-delegation model over earlier event-inheritance model?, How is Java source code files named?, What are the advantages of Java layout managers?
Define class and object. Explain them with an example using java
Class and object - Class: A class is a program construct which encapsulates data and operations on data. In object oriented programming, the class can be viewed as a blue print of an object...
What is a method? Provide several signatures of the methods
What is a method? - A java method is a set of statements to perform a task. A method is placed in a class...
Post your comment
Discussion Board
Nice Post
Awesome post. Very helpful and very important questions are compiled.

Here is a free android app COGNIZE giving a brief knowledge about the technologies used(the latest versions, company that owns it, key features etc.) in software development and testing.

Just give it a try.....
questlab 06-6-2016
core java
like this
deepak 08-23-2015
interview Q&A
core java Q&A for fresher.............................
Arpitha 04-7-2015
I request you to put coding part of array bcoz it is frequently asked in interviews.
Deepak 03-19-2015
I need programming ( Coding)
Will you plz put coding part because Coding knowledge is important for IT job They are checking coding part only.I mean Practical.

Thanks for putting this amazing interview questions
Anjaneya Gupta 06-25-2014
This is nice best Interview Question for the Fresher as well as Other. So thaks again.
Dipak Suthar 06-21-2014
core java
most impartent java interview Q/A
susanta 02-18-2014
java fresher Intrvw Q's
its better,but still more informaion based on index criteria
Srikanth 10-4-2012
Java core Q and A
I m satisfied with question and answer
Manoj patidar 08-15-2012
interview question
this question list is best for fresher preparation
Hitesh 06-27-2012