Pages

Encapsulation Interview Questions



Encapsulation Interview Questions


Hello guys i am Gaurav rawat; Today we discuss some most important interview questions related to Oop's concept. Encapsulation Interview Questions in Java. From this topic lots of questions are asked in any company.

What is Encapsulation in Java ?

Encapsulation is nothing but protecting anything which is prone to change. rational behind encapsulation is that if any functionality which is well encapsulated in code i.e maintained in just one place and not scattered around code is easy to change. 

What is difference between Encapsulation And Abstraction ?

  • 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.
  • 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.
  • Abstraction solves the problem at design level while encapsulation solves the problem at implementation level
  • 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.

What are the features of encapsulation ?

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.



No comments:

Post a Comment

 

Most Reading