You are on page 1of 4

MTS 3053 PROGRAMMING PARADIGM

Quiz

Name: Nurul Aini Binti Abdul Amin Marks: _________________
Matric: D20111048084 Time: 2 Hours

Instruction: Answer all questions.

1. What do you mean by programming paradigms? (3 marks)
Answer:
- A programming paradigm is a style or way of programming. Some languages make it
easy to write in some paradigms but not others.


2. State key features of following paradigms: (12 marks)
a. Procedural programming
b. Object oriented programming
c. Logic programming
d. Functional programming

Answer:
a. Procedural programming
- Execution of computational steps in an order governed by control structures

b. Object oriented programming
- Computation is effected by sending messages to objects; objects have state and
behavior.

c. Logic programming
- Programmer specifies a set of facts and rules, and an engine infers the answers to
questions.

d. Functional programming
- Computation proceeds by (nested) function calls that avoid any global state.








3. Define Object Oriented Programming (OOP) (3 marks)
Answer:
- A type of programming in which programmers define not only the data type of a data
structure, but also the types of operations (functions) that can be applied to the data
structure. In this way, the data structure becomes an object that includes both data and
functions. In addition, programmers can create relationships between one object and
another.


4. Discuss in details the basic concepts of Object Oriented Programming (OOP) (21 marks)

Answers:
Objects
- An object can be considered a "thing" that can perform a set of activities. The set of
activities that the object performs defines the object's behavior.
- It is directly relate to the real world entities.
- Object has an attribute (description of objects in class), method (an action performed
by an object) and identity (unique name)


Classes
- A generic definition for a set of similar objects.
- Provides the specifications for the objects behaviors and attributes.
- An abstraction of a real world entity


Data abstraction
Answer:
- Abstraction is the process of recognizing and focusing on important characteristics of a
situation or object and leaving/filtering out the un-wanted characteristics of that
situation or object.Lets take a person as example and see how that person is abstracted
in various situations

Example :
A doctor sees (abstracts) the person as patient. The doctor is interested in name, height,
weight, age, blood group, previous or existing diseases etc of a person

An employer sees (abstracts) a person as Employee. The employer is interested in name,
age, health, degree of study, work experience etc of a person.






Encapsulation
Answer:
- Encapsulation is a process of tying together all data and methods that form a class and
control the access to data by hiding its information.
- It enables access to object just by using methods of that object.
- It is one of the security features in object-oriented programming (OOP).


Inheritance
Answer:
- Inheritance allows a class to have the same behavior as another class and extend or
tailor that behavior to provide special action for specific needs.


Polymorphism
Answer:
- Polymorphism allows two or more objects respond to the same message.
- Polymorphism allows a sending object to communicate with different objects in a
consistant manner without worrying about how many different implementations of a
message.
- Polymorphism allows the sending object to communicate with receiving objects without
having to understand what type of object it is, as long as the receiving objects support
the messages.


Dynamic binding
Answer:
- Dynamic binding(dispatch) means that a block of code executed with reference to a
procedure(method) call is determined at run time.
- Dynamic dispatch is generally used when multiple classes contain different
implementations of the same method. It provides a mechanism for selecting the
function to be executed from various function alternatives at the run-time. In C++,
virtual functions are used to implement dynamic binding.


Message passing
Answer:
- A type of communication between processes. Message passing is a form of
communication used in parallel programming and object-oriented programming.
Communications are completed by the sending of messages (functions, signals and data
packets) to recipients.




5. List out some of the benefits of OOP (6 marks)
Answer:
- OOP provides a clear modular structure for programs which makes it good for defining
abstract datatypes where implementation details are hidden and the unit has a clearly
defined interface.
- OOP makes it easy to maintain and modify existing code as new objects can be created
with small differences to existing ones.
- OOP provides a good framework for code libraries where supplied software
components can be easily adapted and modified by the programmer. This is particularly
useful for developing graphical user interfaces.


6. List out the applications of OOP (6 marks)
Answer:
- User interface design such as windows, menu ,
- Real Time Systems
- Simulation and Modeling
- Object oriented databases
- AI and Expert System
- Neural Networks and parallel programming
- Decision support and office automation system


7. C++ is a one example of OOP. What are the input and output operators used in C++?
Answer: (6 marks)
Input - cin
Output - cout



8. What is meant by static function? (3 marks)
Answer:
- Static functions are functions that are only visible to other functions in the same file.
- Access to static functions is restricted to the file where they are declared.

You might also like