0% found this document useful (0 votes)
54 views

Lecture 4 OOP - Encapsulation & Abstraction

Encapsulation bundles data and methods into classes and uses access modifiers and getter/setter methods to control access to properties from outside the class. Abstraction hides unnecessary details and shows only essential attributes by using data and process abstraction, abstract classes that cannot be instantiated, and interfaces that define methods but don't implement them. Both help protect data, improve flexibility, and enable code reuse but increase code size and instructions.

Uploaded by

Ramoj Bartowski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Lecture 4 OOP - Encapsulation & Abstraction

Encapsulation bundles data and methods into classes and uses access modifiers and getter/setter methods to control access to properties from outside the class. Abstraction hides unnecessary details and shows only essential attributes by using data and process abstraction, abstract classes that cannot be instantiated, and interfaces that define methods but don't implement them. Both help protect data, improve flexibility, and enable code reuse but increase code size and instructions.

Uploaded by

Ramoj Bartowski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

OOP

Encapsulation &
Abstraction
J. LLEVADO
Encapsulation
 Bundling of data and methods in
class
 Information hiding
How does it work?
Key concepts
 Access modifiers
 Getter or Setter method
Code implementation
Abstraction
 Show only essential attributes
 Hides unnecessary information
How does it work?
Key concepts
 Data abstraction
 Process Abstraction
 Abstract class
 interface
Code implementation
Abstract Class
 a restricted class that cannot be
used to create objects
Interface
 a completely "abstract class" that
is used to group related methods
with empty bodies
Advantages
 Protect your data
 Better testability
 Flexibility
 Code re-usability
Disadvantages
 Code Size
 More Instructions
 Increase code execution
Abstraction
vs.
Encapsulation
thanks!
For questions you may contact me
through our FaceBook group or
email.

You might also like