Which is the Best Java Web Framework ?

Java - Interview Questions and Answers on OOPs Concepts

Q1.  What is difference between Encapsulation And Abstraction?


1.Abstraction solves the problem at design level while encapsulation solves the problem at implementation level

2.Abstraction is used for hiding the unwanted data and giving relevant data. while Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

3. Abstraction lets you focus on what the object does instead of how it does it while Encapsulation means hiding the internal details or mechanics of how an object does something.

4.For example: Outer Look of a Television, like it has a display screen and channel buttons to change channel it explains Abstraction but Inner Implementation detail of a Television how CRT and Display Screen are connect with each other using different circuits , it explains Encapsulation.

Q2.  Difference between Overloading and Overriding ?


Overloading - Similar Signature but different definition , like function overloading.

Overriding - Overriding the Definition of base class in the derived class.

Q3.  Difference between Encapsulation and Data Hiding ?

Ans. Data Hiding is a broader concept. Encapsulation is a OOP's centri concept which is a way of data hiding in OOP's.

Q4.  Difference between Abstraction and Implementation hiding ?

Ans. Implementation Hiding is a broader concept. Abstraction is a way of implementation hiding in OOP's.

Q5.  What are the features of encapsulation ?

Ans. Combine the data of our application and its manipulation at one place.

Encapsulation Allow the state of an object to be accessed and modified through behaviors.

Reduce the coupling of modules and increase the cohesion inside them.

Q6.  Does Java support Multiple Inheritance ?

Ans. Interfaces does't facilitate inheritance and hence implementation of multiple interfaces doesn't make multiple inheritance. Java doesn't support multiple inheritance.

Q7.  Difference between Encapsulation and Data Hiding ?

Ans. Data Hiding is a broader concept. Encapsulation is a OOP's centri concept which is a way of data hiding in OOP's.  

Q8.  Difference between Composition and Inheritance ?

Ans. Inheritance means a object inheriting reusable properties of the base class. Compositions means that an abject holds other objects. 

In Inheritance there is only one object in memory ( derived object ) whereas in Composition , parent object holds references of all composed objects. 

From Design perspective - Inheritance is "is a" relationship among objects whereas Composition is "has a" relationship among objects.  

Q9.  How is Abstraction implemented in Java ?

Ans. Abstraction is provided in Java by following ways -

Coding to the ( Interfaces / Abstract Classes ) or contracts

By Encapsulating details within classes and exposing the minimal Door ( few public methods )

Q10.  Which of the following Java feature promotes access protection or Hiding ?

 a. Inheritance
 b. Encapsulation
 c. Abstraction
 d. Composition

Ans. Encapsulation

Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus


Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.