Cs304 Final Spring 2006
Transcript of Cs304 Final Spring 2006
-
8/8/2019 Cs304 Final Spring 2006
1/6Note: Solve these papers by yourselfVU Cafeteria is not responsible for any solved content
CS304Final Term Examination Spring 2006
Time Allowed: 150 Minutes
Marks : 1
Wh e function that overloads
the+ operator for thecomplexclass?
operator +r
Marks : 3
Wit ers to
n
ct that will be returned from the
function
Wr e Accountas a friend class ofCustomer.
ers ofCustomer class are:
ii. cusAddress
iii. cusbalance
Priv of Accountclass are:
AccTitle
heirto zero.
Question No. 1
at is the name of th1. add2. complexadd3. +4.
5. operato
Question No. 2
hin a member function, theexpression
*this always ref
1. the objects passes as an argument to the
functio2. the address of an
object3. a temporary object created within the
function4. the object that called the
function5. the obje
Question No. 3 Marks : 3
ite two classesCustomer andAccount.Declar
Private datamembi. cusName
ate data
membersi.ii. AccBalance
a) Write parameterized constructors for both classes i.e.
Customer andAccount, to initialize tdata members. ForCustomer class initialize cusbalance
Cafeteria
VUCa
feteria
Page 1 / 6
-
8/8/2019 Cs304 Final Spring 2006
2/6Note: Solve these papers by yourselfVU Cafeteria is not responsible for any solved content
b) Write a member function ofAccountclass, namedsetBalance ( )to assign AccBalance tocusbalance, which is a data member ofCustomer class.
rite a member function for theCustomer class, nameddisplaytData ( )to display the values ofustomerscusName, cusAddress and
cusbalance.
Marks : 1
ven below is a code snippet:rClass
ass();
hods
blic:mbers
ourClass *Yclass;Yclass = new YourClass[3];
Do
2. ided above the private members in the
classan array is being created in the function main,
therefore,or
type of main () is not int
Marks : 1
a) + program which creates a classEmployeewith the following attribute
is class should have a parameterized
constructorand destructor, the getter/setter functions and
a
) Create a class named asSalaried that inherits from classEmployee. A Salaried object has thefoll ute
This class should also have parameterized
constructorand default
destructor
, setter/getter
functions
) Similarly, develop a class named asHourly that inherits from classEmployee. An Hourly object isdist y the following attributes
. hours
WC
Question No. 4
GiClass You
{
private:
YourCl
// other private met
pu// public me
}
void main()
{Y
}
you see any problem with the code
above?1. The class name is invalidThe public members should be
prov3. The constructor is declared private
butthe statement will result in an
err4. The array creating syntax is incorrect5. Return
Question No. 5
Write a C+
1. name
Thvirtual member function calledpay () that returns the salary of theEmployee.
bowing attrib
1. salary
and apay () member function.
cinguished b
12. rate
Cafeteria
VUCa
feteria
Page 2 / 6
-
8/8/2019 Cs304 Final Spring 2006
3/6Note: Solve these papers by yourselfVU Cafeteria is not responsible for any solved content
This class should also have a parameterized
constructor, default
destructor
, setter/getter functions
anda pay () member function.our program should create objects
ofSalaried and Hourly classes and then invoke the pay () function
f these classes polymorphicly (through Employee
Object)
Marks : 1
The dogram in the place of each of function
call tself, but by the
processor
4. occurs only once in the
program
rite a C++ program to determine
the
area andperimeterofrectangleaccording to thelengthand
template .
s the following data member.
: length
he area and perimetershould be calculated for eachint, floatand doubletype data member. Hence
the
ave following member functionsof a template .
his member function will calculate thearea of the rectangle. The area of a rectangle can be calculateda:
his member function will calculate theperimeter of the
rectanglewhere the formula for perimeter of
the area is calculating for a rectangle of int type lengthandwidth, then this member functionshould
ke three instances of one of each type of data
membersint, float, and doublefor the class rectangle
Que n Marks : 1The s t, Which one of the following is a valid destructor for this class
Yo
Question No. 6
co e for an inline function1. is inserted into the
pr2. is not generated by the compiler
i3. takes extra memory
5. is merely symbolic; it is not actually executed
Question No. 7 Marks : 1
W
widthentered by the user. Your code should includea
Your rectangleclass ha
12: width
Tdata member of theclass
rectangleshould be of typeTemplateas well.
Your program should h
1: area ();Tby the following formul
Area = length * width
2: perimeter ();
Trectangle is
Perimeter = 2 *(length + width)
Area() and perimeter()member functions should return the same type on which the data ismanipulating.For exampleIfreturn an integer numberand vice versa.
Tain main ().
Also write setterand getterfor the data member of theclass rectangle.
stio No. 8re i a class Studen
Cafeteria
VUCa
feteria
Page 3 / 6
-
8/8/2019 Cs304 Final Spring 2006
4/6Note: Solve these papers by yourselfVU Cafeteria is not responsible for any solved content
1. Student();2. Student(int);3. ~ Student();4. int~ Student();5. ~ Student(int);
Marks : 1
there any difference between abstract and base class? If yes, then what is
it?
uestion No. 10 Marks : 3
uestion No. 11 Marks : 3
uestion No. 12 Marks : 10
uestion No. 13 Marks : 1
uestion No. 14 Marks : 1
uestion No. 15 Marks : 1
uestion No. 16 Marks : 1
uestion No. 17 Marks : 1
uestion No. 18 Marks : 10
uestion No. 19 Marks : 1
Question No. 9
Is
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Cafeteria
VUCa
feteria
Page 4 / 6
-
8/8/2019 Cs304 Final Spring 2006
5/6Note: Solve these papers by yourselfVU Cafeteria is not responsible for any solved content
Question No. 20 Marks : 1
uestion No. 21 Marks : 1
uestion No. 22 Marks : 1
uestion No. 23 Marks : 1
uestion No. 24 Marks : 1
estion No. 25 Marks : 3
uestion No. 26 Marks : 1
uestion No. 27 Marks : 1
uestion No. 28 Marks : 1
uestion No. 29 Marks : 1
uestion No. 30 Marks : 1
uestion No. 31 Marks :1
Q
Q
Q
Q
Qu
Q
Q
Q
Q
Q
Q
Cafeteria
VUCa
feteria
Page 5 / 6
-
8/8/2019 Cs304 Final Spring 2006
6/6Note: Solve these papers by yourself
Question No. 32 Marks : 1
Cafeteria
VUCa
feteria
Page 6 / 6