Page 322 - Computer_Science_F5
P. 322
Use the relevant material or resources, Encapsulation
including library search, explore other Encapsulation is the binding, or
issues or things that are examples of wrapping, of data and code into a single
abstraction. unit. In Java, encapsulation is similar Chapter Five: Object oriented programming with Java
to keeping important things in a locked
FOR ONLINE READING ONLY
Deliverable: box. It hides inside details and stops
Summary report that includes sketches others from accessing them without
and photographs. permission, making sure the data stays
safe and unchanged.
Document your findings in a portifolio
describing in details how they are
regarded as abstraction. Activity 5.2:
Exploring encapsulation in the
Java allows abstraction through the use surrounding environments
of abstract classes and interfaces.
Aim:
(a) Abstract class To understand encapsulation in OOP
In Java, the “abstract” keyword is a by exploring real-world examples
component of the abstract class. A class where data is protected and secure.
cannot be instantiated if it is declared abstract.
Therefore, you cannot create an abstract Materials: Medical capsule,
class object. Furthermore, both abstract Surrounding environments or Internet
and concrete methods may be present in
an abstract class. Instructions:
Hiding your data so that it is protected
In order to utilise an abstract class, you from modifications is same as
must inherit it from another class and encapsulation. In a medical capsule, the
supply implementations for the abstract medication is always secure inside the
methods. Otherwise, the original class will capsule, is the best way to comprehend
likewise turn into an abstract class. encapsulation. Use the relevant material
or resources, including library search,
(b) Interface explore other issues or things that are
examples of encapsulation.
Interface in Java is a group of abstract
methods and static constants. Every Deliverable:
method in an interface is public, abstract, Summary report that includes
and does not contain a constructor. In sketches, diagrams or photographs.
Java, interfaces aid in achieving multiple
inheritance in addition to abstraction. Document your findings in a portifolio
So an interface is a collection of related describing in details how they are
methods with empty bodies. regarded as encapsulation.
313
Student’s Book Form Five
Computer Science Form 5.indd 313 23/07/2024 12:34

