1.

What Is Encapsulation?

Answer»

As you read articles and books about object-oriented programming and Java, you might ENCOUNTER the term encapsulation. In the simplest sense, encapsulation is the COMBINATION of data and methods into a single data structure. Encapsulation groups together all the components of an object. In the "object-oriented" sense, encapsulation also defines how your programs can reference an object's data. Because you can divide a Java class into public and private sections; you can control the degree to which class users can modify or access the class data. For example, programs can only access an object's private data USING public methods DEFINED within the class. Encapsulating an object's data in this way protects the data from program misuses. In Java, the class is the fundamental TOOL for encapsulation.

As you read articles and books about object-oriented programming and Java, you might encounter the term encapsulation. In the simplest sense, encapsulation is the combination of data and methods into a single data structure. Encapsulation groups together all the components of an object. In the "object-oriented" sense, encapsulation also defines how your programs can reference an object's data. Because you can divide a Java class into public and private sections; you can control the degree to which class users can modify or access the class data. For example, programs can only access an object's private data using public methods defined within the class. Encapsulating an object's data in this way protects the data from program misuses. In Java, the class is the fundamental tool for encapsulation.



Discussion

No Comment Found