Encapsulation Interview Questions in Java


Prev Tutorial Next Tutorial

Interview Questions on Encapsulation in Java

Why use Encapsulation ?

Encapsulation in java is a process of wrapping code and data together into a single unit.

Real life example of Encapsulation ?

Real life example of encapsulation is; capsule is mixed of several medicines.

Advantage of Encapsulation in java ?

  • Encapsulated Code is more flexible and easy to change with new requirements.
  • Encapsulation in Java makes unit testing easy.
  • Encapsulation in Java allows you to control who can access what.
  • Encapsulation allows you to change one part of code without affecting other parts of code.

What are the features of encapsulation ?

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

What is difference between Encapsulation And Abstraction ?

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

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

  • Inheritance
  • Encapsulation
  • Abstraction
  • Composition

Ans: Encapsulation

What is difference between Encapsulation and Abstraction ?

Abstraction solves the problem at design level.Encapsulation solves the problem at implementation level
It is used for hiding the unwanted data and giving relevant data.hiding the code and data into a single unit to protect the data from outside world.
It focus on what the object does instead of how it does it.It hiding the internal details or mechanics of how an object does something.
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.

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

wifi cctv camera

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223
wifi cctv camera

Wifi CCTV Camera RS:1200 to 2499.

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs