# Module 10: Encapsulation and Abstraction

MODULE OVERVIEW

This module covers encapsulation and abstraction, two important principles of
object-oriented programming in Java.



Learners will understand how encapsulation protects data within a class and how
abstraction simplifies application design by exposing essential functionality
while hiding implementation details.



The module explores private data members, getter and setter methods, data
hiding, abstract classes, abstract methods and interfaces.



Learners will also understand the differences between abstract classes and
interfaces and how to apply them when designing Java applications.






WHAT WILL BE COVERED


10.1 ENCAPSULATION

 * Understanding the concept of encapsulation in Java.

 * Exploring how data and methods are grouped within a class.

 * Understanding how encapsulation controls access to object data.

 * Learning how access modifiers support encapsulation.

 * Applying encapsulation to organise application components.

 * Exploring practical examples of encapsulated classes.


10.2 PRIVATE DATA MEMBERS

 * Understanding the purpose of private access modifiers.

 * Declaring private variables within a class.

 * Learning how private members restrict direct access from outside the class.

 * Understanding how class methods can access private data.

 * Applying private data members to protect sensitive application information.


10.3 GETTER AND SETTER METHODS

 * Understanding the purpose of getter and setter methods.

 * Creating getter methods to retrieve private variable values.

 * Creating setter methods to update private variable values.

 * Controlling how data is accessed and modified.

 * Applying validation logic within setter methods.

 * Using getter and setter methods to manage object information.


10.4 DATA HIDING

 * Understanding the concept of data hiding in Java.

 * Restricting direct access to internal class data.

 * Using private variables to protect object information.

 * Controlling data access through public methods.

 * Understanding the relationship between data hiding and encapsulation.

 * Applying data hiding to improve application security and data management.


10.5 ABSTRACT CLASS

 * Understanding the purpose of abstract classes.

 * Declaring abstract classes using the abstract keyword.

 * Exploring the characteristics of abstract classes.

 * Understanding why abstract classes cannot be instantiated directly.

 * Defining constructors, variables and methods within abstract classes.

 * Extending abstract classes using child classes.

 * Applying abstract classes to represent common application structures.


10.6 ABSTRACT METHOD

 * Understanding the concept of abstract methods.

 * Declaring methods without implementation.

 * Understanding how subclasses provide method implementations.

 * Exploring the relationship between abstract classes and abstract methods.

 * Overriding abstract methods in child classes.

 * Applying abstract methods to define common behaviour across related classes.


10.7 INTERFACE

 * Understanding the purpose of interfaces in Java.

 * Declaring interfaces using the interface keyword.

 * Defining methods within interfaces.

 * Implementing interfaces using the implements keyword.

 * Understanding how classes provide implementations for interface methods.

 * Implementing multiple interfaces in a class.

 * Applying interfaces to develop flexible and reusable application structures.


10.8 DIFFERENCE BETWEEN ABSTRACT CLASS AND INTERFACE

 * Understanding the purpose of abstract classes and interfaces.

 * Comparing their declarations and implementation approaches.

 * Exploring differences in constructors and instance variables.

 * Understanding abstract and concrete methods.

 * Comparing class inheritance and interface implementation.

 * Understanding when to use an abstract class or an interface.

 * Selecting suitable approaches based on application design requirements.


SKILLS YOU WILL GAIN

 * Understanding encapsulation and abstraction in Java.

 * Defining private data members.

 * Creating getter and setter methods.

 * Applying data hiding techniques.

 * Developing and extending abstract classes.

 * Declaring and implementing abstract methods.

 * Creating and implementing interfaces.

 * Understanding the differences between abstract classes and interfaces.

 * Designing reusable and maintainable object-oriented components.


LEARNING OUTCOMES

By the end of this module, learners will be able to:

 * Apply encapsulation to organise application data and control access to
   business information.

 * Use private data members to protect sensitive details such as customer,
   employee and account information.

 * Develop getter and setter methods to retrieve and update data with
   appropriate validation.

 * Implement data hiding to reduce unauthorised or unintended changes to
   application data.

 * Design abstract classes to define common structures for related business
   entities.

 * Use abstract methods to ensure that child classes implement required
   application behaviours.

 * Create and implement interfaces to support flexible application design.

 * Select between abstract classes and interfaces based on application
   requirements.

 * Develop structured, reusable and maintainable Java applications using
   object-oriented principles.


CERTIFICATION ALIGNMENT

This module develops Java object-oriented programming knowledge that supports
the broader learning pathway towards the Oracle Certified Professional: Java SE
17 Developer certification.

The topics covered help learners understand encapsulation, data protection,
abstract classes, abstract methods and interfaces within Java application
development.


CONTINUE TO THE NEXT MODULE

Continue to Module 11: Packages and Access Modifiers to learn how Java packages
organise classes, how access modifiers control visibility and how to work with
built-in packages, user-defined packages and static imports.