Object-Oriented Programming: Abstraction and Classes

SociableSanctuary avatar
SociableSanctuary
·
·
Download

Start Quiz

Study Flashcards

10 Questions

What type of association is assumed in UML, unless otherwise specified?

Bidirectional

What does the arrowhead in a unidirectional association point to?

The known class

Where are multiplicity notation symbols typically placed?

Near the ends of an association

What does the '+' symbol indicate in UML?

Public visibility

What type of relationship is established through inheritance?

Generalization

What is the direction of the arrowhead in a generalization relationship?

From the subclass to the superclass

What is the 'is a kind of' relationship also known as?

Generalization

What type of relationship indicates a 'uses' relationship between two classes?

Dependency

What is the purpose of multiplicity notations in UML?

To indicate the number of instances of a class

What type of association is represented by a solid line with no arrowhead?

Bidirectional

Study Notes

Data Abstraction

A concept that represents essential features without including background details or explanations

Classes use data abstraction and are defined as a list of attributes (e.g. size, weight, cost) and functions to operate on these attributes

Encapsulates all essential properties of an object to be created

Attributes are called data members, as they hold data, and functions that operate on this data are called member functions

Classes use data abstraction, making them abstract data types (ADTs)

Inheritance

Mechanism by which one class can inherit properties of another

Allows for building a hierarchy of classes, from most general to most specific

Base class defines common qualities, and derived class inherits these and adds specific properties

Provides reusability in OOPs, with base class representing general description and derived class adding specific traits

Polymorphism

Ability to take more than one form

Example: an operation has different behavior in different instances, depending on data type used

Achieved through function overloading and operator overloading in C++ programs

Binding

Linking a procedure call to code executed in response to the call

Dynamic binding: code associated with a procedure call is not known until run-time, depending on polymorphic reference

Message Passing

Involves specifying object name, function (message) name, and information to be sent

Object-oriented program consists of objects communicating with each other through message passing

Unified Modeling Language (UML)

General-purpose modeling language

Includes concepts like association (unidirectional and bidirectional), multiplicity, visibility, generalization, and dependency

Association

Unidirectional: two classes are related, but only one class knows the relationship exists

Bidirectional: both classes are aware of each other and their relationship

Multiplicity: indicates number of instances of one class linked to one instance of another class

Visibility

Signifies who can access information contained within a class

Denoted with +, -, # symbols

Generalization

Relationship between a general thing (superclass) and a more specific kind of that thing (subclass)

Established through inheritance, represented by a solid directed line with a large open arrowhead pointing to the parent class

Dependency

Indicates a "uses" relationship between two classes

Understand the concept of abstraction in object-oriented programming, including classes, attributes, and member functions. Learn how to define and use classes to represent objects and their properties.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser