Você está na página 1de 6

WWW.VUTUBE.EDU.

PK
www.vustuff.com

CS304
Final Term Examination – Spring 2006
Time Allowed: 150 Minutes

Question No. 1 Marks : 1

Wh at is the name of the function that overloads + operator for thecomplexclass?


1. add the
2. complex add
3. +
4. operator +
5. operator

Question No. 2 Marks : 3

Wit hin a member function, the *this always ref ers to


expression
1. the objects passes as an argument to the n
2. the address
functio of an
3. a temporary object created within the
object
4. the object that called the
function
object that will be returned from the
function
5. the
function
Question No. 3 Marks : 3

Wr ite two classes Customer and Account. Declar e Account as a friend class of Customer.

Private data ers of Customer class are:


memb
i. cusName
ii. cusAddress
iii. cusbalance

Priv ate data of Account class are:


members
i. AccTitle
ii. AccBalance

a) Write parameterized constructors for both classes i. Customer and Account, to initialize their
e. members. ForCustomer class initialize cusbalance to zero.
data
b) Write a member function ofAccount class, named setBalance ( ) to assign AccBalance to
cusbalance, which is a data member ofCustomer class.
W rite a member function for theCustomer class, named displaytData ( ) to display the values of
C ustomer’s cusName, cusAddress and
cusbalance.

Question No. 4 Marks : 1

Gi ven below is a code snippet:


Class You rClass
{
private:
YourCl ass();
// other private met hods
public:
// public me mbers
}
void main()
{
Y ourClass *Yclass;
Yclass = new YourClass[3];
}

Do you see any problem with the code


above?
1. The class name is invalid
2. The public members should be ided above the private members in the
3. The
provconstructor is declared privateclass
an array is being created in the function main,
the statement will result in an or therefore,
but
4. err
The array creating syntax is incorrect
5. Return type of main () is not int

Question No. 5 Marks : 1

a) Write a C+ + program which creates a classEmployee with the following attribute

1. name

Th is class should have a parameterized and destructor, the getter/setter functions and
virtual member functionconstructor a
calledpay () that returns the salary of theEmployee.

b) Create a class named asSalaried that inherits from classEmployee. A Salaried object has the
foll owing attribute

1. salary

This class should also have parameterized and default , setter/getter


constructor
and a pay () member function. destructor functions

c) Similarly, develop a class named as Hourly that inherits from classEmployee. An Hourly object is
distinguished by the following attributes

1. hours
2. rate
This class should also have a parameterized , default , setter/getter functions
a pay () member function. constructor destructor and
Y our program should create objects Salaried and Hourly classes and then invoke the pay () function
ofof
these classes polymorphicly (through Employee
Object)

Question No. 6 Marks : 1

The code for an inline function


1. is inserted into the ogram in the place of each of function
2. isprnot generated by the
callcompilertself, but by the
i
3. takes extra memory processor
4. occurs only once in the
5. isprogram
merely symbolic; it is not actually executed

Question No. 7 Marks : 1

W rite a C++ program to determine area and perimeterof rectangleaccording to thelengthand


the entered by the user. Your code should include template <class T>.
width
a
Your rectangleclass has the following data member.

1: length
2: width

T he area and perimetershould be calculated for eachint, float and doubletype data member. Hence
data member of theclass should be of typeTemplate as well. the
rectangle
Your program should have following member functionsof a template <class T>.

1: area ();
T his member function will calculate thearea of the rectangle. The area of a rectangle can be calculated
by the following formula:

Area = length * width

2: perimeter ();

T his member function will calculate theperimeter of the where the formula for perimeter of
rectangle is rectangle

Perimeter = 2 *(length + width)

Area() and perimeter()member functions should return the same type on which the data is
manipulating.For example
If the area is calculating for a rectangle of int type lengthand width, then this member functionshould
return an integer numberand vice versa.

Ta ke three instances of one of each type of data int, float, and doublefor the class rectangle
members’
in main ().

A lso write setterand getterfor the data member of theclass rectangle.

QuestionNo. 8 Marks : 1
There isa class Studen t, Which one of the following is a valid destructor for this class
1. Student();
2. Student(int);
3. ~ Student();
4. int~ Student();
5. ~ Student(int);

Question No. 9 Marks : 1

Is there any difference between abstract and base class? If yes, then what is
it?

Q uestion No. 10 Marks : 3

Q uestion No. 11 Marks : 3

Q uestion No. 12 Marks : 10

Q uestion No. 13 Marks : 1

Q uestion No. 14 Marks : 1

Q uestion No. 15 Marks : 1

Q uestion No. 16 Marks : 1

Q uestion No. 17 Marks : 1

Q uestion No. 18 Marks : 10

Q uestion No. 19 Marks : 1


Question No. 20 Marks : 1

Q uestion No. 21 Marks : 1

Q uestion No. 22 Marks : 1

Q uestion No. 23 Marks : 1

Q uestion No. 24 Marks : 1

Qu estion No. 25 Marks : 3

Q uestion No. 26 Marks : 1

Q uestion No. 27 Marks : 1

Q uestion No. 28 Marks : 1

Q uestion No. 29 Marks : 1

Q uestion No. 30 Marks : 1

Q uestion No. 31 Marks :1


Question No. 32 Marks : 1

Você também pode gostar