adspace


Explain the encapsulation principle.

Answer Posted / Yash Kumar

The Encapsulation principle is a key concept in object-oriented programming that helps to hide the internal details or implementation of an object from the outside world. This hiding mechanism protects the object's state and behavior from being directly accessed by other objects, making the system more modular, secure, and easier to maintain. In Java, encapsulation is achieved by declaring variables as private and providing public methods (getters and setters) to access those variables.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we extract main method from another class?

1034


What is the first argument of the string array in main method?

1030


what is reflection api? How are they implemented?

1105


Are jvm’s platform independent?

982


What if I write static public void instead of public static void?

934


What do you understand by casting in java language? What are the types of casting?

923


What is the java api?

994


What is the resourcebundle class?

1012


What is the locale class?

1024


How does java handle integer overflows and underflows?

1114