We have our semester sessional programming exam in one hour
Four principles of object oriented programming:
- Data Abstraction
Any representation of data in which the implementation details are
hidden (abstracted). Abstract data types
and objects are the two primary forms of data
The ability to provide users with a well-defined interface to a set of functions
in a way which hides their internal workings. In object-oriented
programming, the technique of keeping together data structures and the
methods (procedures) which act on them.
The ability to derive new classes from existing
classes. A derived class (or
“subclass”) inherits the instance
variables and methods of the base
class and may add new instance variables
and methods. New methods may be defined with the same names as those in the base
class, in which case they override the original one.
For example, bytes might belong to the class of integers for which an add method
might be defined. The byte class would inherit the add method from the integer
Polymorphism refers to the ability to define multiple classes with
functionally different, yet identically named methods or properties that can be
used interchangeably by client code at run time.
Is a function which operates on a list of objects of any type. This is known
as parametric polymorphism. Polymorphic typing allows strong type checking as
well as generic functions.
Ad-hoc polymorphism (better described as overloading)
is the ability to use the same syntax for objects of different types, e.g.
“+” for addition of reals and integers or “-” for unary
negation or diadic subtraction. Parametric polymorphism allows the same object
code for a function to handle arguments of many types but overloading only
reuses syntax and requires different code to handle different types.