Why do we use Java encapsulation?

Answer: The major advantage of encapsulation in Java is data hiding . Using encapsulation we can allow the programmer to decide on the access to data and methods operating on that data. For example, if we want a particular piece of data to be inaccessible to anyone outside the class, then we make that data private.

Sizin İçin Seçtik  How many base classes are there in hierarchical inheritance?

Leave a Reply

Your email address will not be published. Required fields are marked *

Why do we use Java encapsulation?

Answer: The major advantage of encapsulation in Java is data hiding . Using encapsulation we can allow the programmer to decide on the access to data and methods operating on that data. For example, if we want a particular piece of data to be inaccessible to anyone outside the class, then we make that data private.

Sizin İçin Seçtik  How can I learn Swift book?

Leave a Reply

Your email address will not be published. Required fields are marked *