Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CSC241: Object Oriented Programming

Course teacher: Kanwal Saeed

FA14-BSSE-068 WALEED SAGHER

1st Sessional Examination

Object Oriented Programming-CSC241

Deadline: 19th April, 2015


Max Marks: 20
Question 1:
(5)
Give concrete examples of classes and objects from real life briefly depicting why you think so.
Answer
Class:
A class is well defined group of objects. When you define a class, you define a blueprint for a data type. This doesn't actually
define any data, but it does define what the class name means, that is, what an object of the class will consist of and what
operations can be performed on such an object.
Example:
1. While building a house the map or blueprint (on paper) of the house is a class, because it contains all the necessary
information about each components (e.g. doors, windows, alarm system, ventilation system etc.)
2. Flow chart of software is actually the class because it contains all the necessary information about the functionality of
the software.

Object:
When you define a class, you define a blueprint for a data type. This doesn't actually define any data, but it does define what the
class name means, that is, what an object of the class will consist of and what operations can be performed on such an object.
An object must have state and behavior.
Example:
LED switch button is the object of the class Electrical circuit because it has only one state ON/OFF and two behaviors ON and
OFF.
Software is the object of class Software Flowchart and it may has multiple states and multiple behaviors.

Question 2:
(5)
What are private members and how are they accessed from the public members in the main ().
Answer
Private Members:
A member (either data member or member function) declared in a private section of a class can only be accessed by member
functions and friends of that class.

Question 3:
(10)
Write a class with name Time. Make a constructor which calculates the given time in minutes {if input
time is 1hr, then the constructor should return 60minutes.}.
CSC241: Object Oriented Programming
Course teacher: Kanwal Saeed

Solution
CSC241: Object Oriented Programming
Course teacher: Kanwal Saeed

Make another constructor which calculates the time in seconds. {If the input time is 1hr, then the
constructor should return 60*60=3600 seconds}.
Display the contents of both the constructors.
Solution
CSC241: Object Oriented Programming
Course teacher: Kanwal Saeed

BEST OF LUCK! 

You might also like