Académique Documents
Professionnel Documents
Culture Documents
Date: 26-09-16
Duration: 30 minutes
Marks: 20
Q1. We have a class named Sales with a method name CalculateSales(). We need to use it in the
class WinterSales, class SummerSales. So for every class we use the CalculateSales() method but
with different attributes. Mention which key concept of object-oriented does this scenario refer to
and define that concept. (05)
Ans. This concept refers to Polymorphism.
Polymorphism is defined as the implementation of the same method with different
attributes in a different context.
Q2. (a) Write any four differences between Abstraction and Encapsulation. (04)
Ans.
Abstraction Encapsulation
1. Abstraction solves the problem at the 1. Encapsulation solves the problem in the
design level. implementation level.
2. Abstraction hides unwanted data 2. Encapsulation means hiding the code and
and provides relevant data. data into a single unit to protect the data
from the outside world.
3. Abstraction lets you focus on what the 3. Encapsulation means hiding the internal
object does instead of how it does it details or mechanics of how an object does
something.
4. Abstraction: Outer layout, used in terms 4. Encapsulation: Inner layout, used in
of design. terms of implementation.
(b) Write any three differences between Structured Programming and Object-oriented
Programming. (03)
Ans.
OO Process Model
Ans. Object-oriented model is a representation of a piece of software as a set of
objects interacting between each other, with a goal to reduce the complexity of the
system and enable developers to work on a specific object, while treating other
objects as black boxes, with the requirement to know only their interfaces, and not
their actual implementation.
Class
Ans. A class is grouping of objects with similar properties. A class is a blueprint of
an object that contains variables for storing data and functions to perform
operations on the data.
Objects
Ans. Objects are instances of any class and primary run-time entities that make
sense in a specific application. They may represent a person, a place or any item that
the program must handle. To work with the data represented by the class a variable
for the class must be created, that is called an object.
Inheritance
Ans. When a class includes a property of another class it is known as inheritance.
Inheritance is a process of object reusability. Inheritance is a feature by which a
class acquires attributes of another class.