D.1 Oop-1
D.1 Oop-1
1 OOP
Object - an abstract entity describing the data it contains (known as
properties or attributes) and the actions it can perform (known as methods)
Class - a template for an object, containing definitions for characteristics of an
object but no values assigned to it
Difference between class and instantiation of class - M23 marking scheme
Aggregation - one object belongs to another object and none other, but
both can exist independently.
a guest can only be assigned to one room and none other, but both
can exist without the other
Denoted by a solid line beginning in a diamond
advantages:
object actions may have the same name but different parameters
returning different outputs
subclasses may have their own unique actions and are able to
override superclass actions
disadvantage of OOP - for smaller projects, OOP may increase complexity,
development time and maintenance costs
Definitions
Instance variable - the specific value of a variable in an object
Parameter variable - the data items passed to a function as a parameter
Local variable - a variable declared within a block of code that are only
usable
Accessor - a method that is used to read the value of a variable of an
object. used if the object is private
Mutator - a method that is used to modify the value of a variable of an
object. used if the variable is private
Constructor - a method that is called when an object is instantiated.
usually used to initialize the variables of the object
Return value - the value that is passed back once a method is executed.
if the return type is void, no value needs to be returned
Access modifiers
Private - only accessible by the class that defines it
Protected - only accessible by the class that defines it, and subclasses
that extend from it
Public - accessible by any class
Extends - indicates that one class inherits from another class
Static - a value that belongs to the class itself and not the objects of the
class. the value is the same across all objects even when modified
Static variable - M23 marking scheme