Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

OOP - Mod 4 - Realization, Lecture notes of Programming Paradigms

The relationship between two model elements, realization, and the concept of interfaces and abstract classes in Object-Oriented Programming (OOP) paradigm. It describes the characteristics of interfaces and abstract classes, how they are implemented, and why they are used. The document also provides examples of interfaces and abstract classes in Java and UML. The main purpose of this document is to provide a basic understanding of interfaces and abstract classes in OOP paradigm.

Typology: Lecture notes

2020/2021

Available from 04/02/2022

gwen-hermo
gwen-hermo 🇵🇭

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mod 4
Realization, Interfaces and Abstract Classes
Realization
a relationship between two model elements, in which one model element realizes
the behavior that the other model element specifies.
one entity denotes some responsibility which is not implemented by itself and the
other entity that implements them. This relationship is mostly found in the case of
interfaces.
Interfaces
a group of related methods with empty bodies
Abstract by default, methods are in the form of an unimplemented
function signature
An interface can be implemented by a class
it is inherited using the keyword, implements.
All methods of an interface must be mandatory implemented on all classes
implementing a specific interface.
Don’t have an attribute
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download OOP - Mod 4 - Realization and more Lecture notes Programming Paradigms in PDF only on Docsity!

Mod 4

Realization, Interfaces and Abstract Classes

Realization ➢ a relationship between two model elements, in which one model element realizes the behavior that the other model element specifies. ➢ one entity denotes some responsibility which is not implemented by itself and the other entity that implements them. This relationship is mostly found in the case of interfaces. Interfaces ➢ a group of related methods with empty bodies

  • Abstract – by default, methods are in the form of an unimplemented function signature → An interface can be implemented by a class → it is inherited using the keyword, implements. → All methods of an interface must be mandatory implemented on all classes implementing a specific interface. → Don’t have an attribute

Abstract Classes → Have an attribute ➢ If a class includes abstract methods, then the class itself must be declared abstract. → cannot be instantiated/created → can only be base/parent class or a class that can be inherited by another class. → When an abstract class is inherited , the subclass usually provides implementations for all of the abstract methods in its parent class. → if it does not , then the subclass must also be declared abstract. Why interfaces are implemented/created in OOP paradigm? ➢ There are classes that are not inherited in a singular object, different elements but maybe they have something in common in behavior. → Two or more classes have the same behavior even though not from a same parent class, use realization relationship and create interface. List https://docs.oracle.com/javase/8/docs/api/java/util/List.html

REALIZATION

Test Main Method

SINGLETON

Used when objects are necessarily one, restrict more instances of class Default Constructor: Normal Constructor:

  • Eliminate redundancy through Interface and Abstract Class
  • Drink abstract class