Jan 17

java developer interview questions part 38

194) Explain what is encapsulation?

Encapsulation is the process of wrapping of code and behaviour in a single unit called class and preventing from misuse is called encapsulation. Encapsulation exposes only part of object which are safe to exposed and remaining part of object is kept secured.

Encapsulation is supported through access control in java. There are four types of access control specifiers(public,private, protected, default)  in java which supports encapsulation.

For example tv manufacturers exposes only buttons not all the thousands of electronic components which it is made up of.

195)  What is inheritance ?

Inheritance is one of the important feature of object oriented language. Inheriting is the process of acquiring features of others. For example a child acquires the features of their parents.

In java inheritance is the process of inheriting member of existing classes by extending their functionality.

The original class is called base class, parent class or super class. The new class derived from parent is called child class, sub class, and derived class.

We use extends keyword in java to extend a class in java. All java classes extend java.lang.Object since object class is  the super class for all  classes in java.

When we create a new class by using inheritance ‘is-a’ relationship is formed.

196)  Explain importance of inheritance in java?

Reusability :The major advantage of inheritance is code reuse. We can avoid duplicating code by using inheritance. We can place all common state and behaviour in that class , by extending that class we can

Extendability : We can add  new functionality to our application without touching the existing code.

For example if we take Ms word we came across number of versions of msword such as word 2003,2007. Everytime they won’t write new code they reuse the existing code and some more features.

197) What is polymorphism in java?

Polymorphism is combination of two greek words which mean many forms. In polymorphism actual type of object involved in method call determines which method to call rather type of reference variable.

59) What is covariant return ?

In java 1.4 and earlier one method can override super class method if both methods have same signature and return types.

From Java 1.5 , a method can override other method if argument types match exactly though return types are different.(Return type must be subtype of other method).

Example : Class A


A doSomeThing()


return new A();



Example : Class B


B doSomeThing()


return new B();



From java 1.5 return type for doSomeThing() in Class B is valid . We get compile time error in 1.4 and earlier.

Jan 16

Top java interview questions part 37

189)  Explain about procedural programming language or structured programming language  and its features?

In traditional programming language to solve a problem we use set of procedures. Once the procedures or functions are determined next they concentrate on storing data.

Features :

1)      In this top down approach is followed. First procedures were determined and then concentrate on minute details.

2)      Concentrate more on functions and procedure rather than data.

3)      In traditional programming language procedures manipulate global data without knowing to other procedures.

4)      Very little concentration on minute details

The main drawback of traditional programming languages works well  only for small problems. But not suitable for larger problems.

Ex : C language, Pascal


190) Explain about object oriented programming and its features?

Java replaced traditional programming language developed in 1970’s. In Object oriented programming everything is made up of object. In this language bottom up approach is followed. Each object  communicates with other as opposed to traditional view.

Features :

1)      In this bottom approach is followed. First concentrates on minute details like creating objects then concentrates on implementation or solving the problem.

2)      Concentrate more on data and give less importance for implementation.

3)      Objects communicate with each other

The main advantage of object oriented programming language is works well for larger problems.


191) List out benefits of object oriented programming language?

1) Easy maintenance

2) Code reusability

3) Code extendability

4) Reliable

192) Differences between traditional programming language and object oriented programming language?

Traditional Programming language Object Oriented Programming Language
A program is divided in to modules and procedures. A program is divided in to number of objects.
Implementation is done through procedures. Implementation is done through interfaces.
In traditional programming there is no encapsulation all procedures access data. In oops encapsulation is done by tightly coupling data and behaviour together in class.
Suitable for small programs or problems Suitable for large programs and complex problems.


 193)  Explain oops concepts in detail?

Object oriented programming should support these three features :

1)      Inheritance

2)      Encapsulation

3)      Polymorphism


Jan 16

core java interview questions part 36

184) Explain about field hiding in java?

If superclass and subclass have same fields subclass cannot override superclass fields. In this case subclass fields hides the super class fields. If we want to use super class variables in subclass we use super keyword to access super class variables.


185)  Explain about Varargs in java?

Beginning with Java 5 has a new feature Varargs which allows methods to have variable number of arguments. It simplifies creation of methods when there are more number of arguments. Earlier to java 5 Varargs are handled by creating method with array of arguments.

Ex : public static void main(String[] args)

A variable length argument is specified using ellispses with type in signature. main method with var args is written as follows:

public static void main(String … args)

If no arguments are passes we get array with size 0.There is no need for null check if no arguments are passed.


186) Explain where variables are created in memory?

When we declare variables variables are created in stack. So when the variable is out of scope those variables get garbage collected.


187) Can we use Switch statement with Strings?

Prior to Java 7 we can use only int values and enum constants in Switch .Starting with Java 7 we can use strings in Switch statement. If we use strings in switch statement prior to Java 7 we will get compile time error  “only int and enum constants are permitted”.


188) In java how do we copy objects?

In Java we cannot copy two objects but by assigning one reference to other we can copy objects. For example if we have a reference r1 that point to object .so when we declare r2=r1, we are assigning reference r1 to r2 so now r2 points to the same object where r1 points. Any changes done by one reference on an object will reflect to other.

Jan 02

Deloitte India hiring freshers and experienced | Jan 2013

Job  Posted Date 2nd Jan
Company` Deloitte India Pvt Ltd
Experience 0-2 years
Designation Software developer
Industry IT
Location Hyderabad
Education UG –B.E/ B.Tech/B.Sc/M.E/M.TechPG-PG not required,Any Doctorateor no Doctorate required
Technical Skills Refer click to apply link to know technic al skills
Official website http://www.deloitte.com
Click here to apply