OOP LESSON 1.pdf
Document Details
Uploaded by CostSavingBromine
Bulacan State University
Full Transcript
OOP CONCEPTS MARY ROSE C. COLUMBRES Bulacan State University - Sarmiento Campus OBJECTIVES: At the end of this lesson, you should be able to: Discuss the six key OOP concepts; Explain all examples of six key OOP concepts; and Identify abstract classes and Interface THE SIX KEY CONCEP...
OOP CONCEPTS MARY ROSE C. COLUMBRES Bulacan State University - Sarmiento Campus OBJECTIVES: At the end of this lesson, you should be able to: Discuss the six key OOP concepts; Explain all examples of six key OOP concepts; and Identify abstract classes and Interface THE SIX KEY CONCEPTS OF OOP 1) Objects 2) Classes 3) Abstraction 4) Inheritance 5) Encapsulation 6) Polymorphism 1. OBJECTS AND 2. CLASSES Object – it is anything that represents “things” in the real world. Two components 1) Attributes – characteristics that define an object. 2) Methods – it is a self-contained block of program code that is similar to a procedure or function. Example: Car’s Attribute Method Model Name Forward Year Backward Purchase Price Break https://www.pawangaria.com/post/java/object-oriented-programming-concepts/ Car Attributes Car Methods Model Steer Color StepOnBreak BrandName StepOnGasPedal 1. OBJECTS AND 2. CLASSES Classes itis a term that describes a group or collection of objects with common properties (both attributes and methods). It is an abstract description of an object – a general plan or blueprint for an object. It specifies methods and data that type of object has. Example: 1) Employee 2) Car 3. ABSTRACTION It allows a programmer to hide all but the relevant information about an object in order to reduce complexity and increase efficiency. Closely related to encapsulation and information hiding. 3. ABSTRACTION https://www.quora.com/Why-to-use-abstraction-in-Java https://www.slideshare.net/bobrenjc93/lesson-203-18-sep131500ay 4. ENCAPSULATION Refers to the hiding of data (attributes) and methods within an object. It hides the details of an object’s internal implementation from the users of an object. It is important, because it separates how an object behaves from how it is implemented. Advantage of Encapsulation It protects an object’s data from corruption It protects the object’s data from arbitrary and unintended use. It is easier to modify programs using encapsulation, because one object type is modified at a time 4. ENCAPSULATION https://techvidvan.com/tutorials/java-encapsulation/ 5. INHERITANCE Itis the process by which objects can acquire (inherit) the properties of objects of another class. It provides reusability, like adding additional features to an existing class without modifying it. This is achieved by deriving new class called subclass or derive class. 5. INHERITANCE https://www.edureka.co/blog/object-oriented-programming/ https://codestall.wordpress.com/2017/09/20/inheritance-in-java/ 6. POLYMORPHISM Refers to the ability to process objects differently depending on their data type or class. It is the ability to redefine methods from derived classes. Can request for an operation without knowing which specific method should be invoked. These implementation details are hidden from the user. 6. POLYMORPHISM https://techvidvan.com/tutorials/java-polymorphism/ ABSTRACT CLASSES It is class that is not used to create (instantiate) objects. It is designed to act as a base class (to be inherited by other classes). It is a design concept in program development and provides a base upon which other classes are built. It can only specify members that should be implemented by all inheriting class. ABSTRACT CLASSES https://www.tes.com/lessons/LQrtpNuBqW4gxA/animal-classification INTERFACE It allow you to create definitions for component interaction. It provide another way of implementing polymorphism. It specify methods that a component must implement without actually specifying how the method is implemented. INTERFACE https://javatutorial.net/java-interface-example Quote of the day