Beruflich Dokumente
Kultur Dokumente
3. Debug code
4. Document activities
5. Test code
ASSESSMENT CRITERIA:
Learning Outcome 2
Apply basic Object Oriented principles in the target language
Learning Objective:
Programming Paradigm
There are two most common approaches to writing computer
programs.
These are:
Procedural programming
Object-oriented programming
What is OOP?
When you travel in a car, however, you dont have to know the
details of how these operations work. To stop a car, for example, you
simply step on the brake pedal. You dont have to know how the pedal
stops the car.
You simply know that it works. All these functions and data work
together to define the object called a car. Furthermore, all these
functions work very similarly from one car to the next. Youre not likely
to confuse a car with a dishwasher, tree, or playground. A car is a
complete unit an object with unique properties.
MULTIPLE CHOICE
Direction: Choose the correct answer from the choices given. Write
your answer in your answer sheet.
a. JAVA c. C
b. C++ d. Smalltalk
a. Object c. Method
b. Data Structure d. Procedure
Multiple Choice
1. A
2. C
3. B
4. B
5. B
Learning Objective:
Exemptions
Hire
Position Promote
Salary Change phone
Phone extension Extension
Figure 1.2
Abstraction
In OOP, abstraction is one of three central principles along with
encapsulation and inheritance. Abstraction is a programming feature
that allows a programmer to hide all but the relevant information (to the
problem at hand) about an object in order to reduce complexity and
increase efficiency. A programmer would use abstraction, for example, to
note that two functions perform almost the same task and can be
combined into a single function. For example (Figure 1.3), your Honda
car may be treated as a common car most of the time (e.g., when driving
the car), as a Honda car when attributes specific to Honda cars are
required (e.g., when replacing specific components/parts), or as your
specific Honda car (e.g., when selling the car).
Figure 1.3
Illustration of encapsulation
Figure 1.4
Inheritance
Illustration of inheritance
Figure 1.5
Polymorphism
Illustration of polymorphism
Figure 1.6
In the given figure (refer to Figure 1.6), both Student and Car have
an instance existing in class Application Form. Notice that both Student
class and Car class have the isRegistered() method. However, the way a
student registers is different from the way a car registers. For instance,
when a student number is required in the process when a student
registers. On the other hand, the registration of a car does not need
information such as a student number but rather say the chassis and
engine numbers.
For example (refer to Figure 1.7), you can create an abstract class
Shape which will be the base class of different polygons. All members of
the class Shape will be inherited by the subclasses created from Shape.
However, you cannot create an object directly from the abstract class
Shape.
Interfaces
Inheritance
SELF-CHECK 3.2-2
MULTIPLE CHOICE
Direction: Choose the correct answer from the choices given. Write
your answer in your answer sheet
a. Interfaces c. Polymorphism
b. Class d. Abstraction
a. Interfaces c. Polymorphism
b. Class d. Constructor
a. Constructor b. Object
c. Interfaces d. Abstraction
a. Interfaces c. Inheritance
b. Class d. Object
Multiple Choice
1. B
2. A
3. C
4. C
5. D
6. B
7. D
8. A