VUDESK

¤Virtual University Of Pakistan Network¤



Welcome Visitors to VUDESK Family .Join VUDESK For Free to Get more Access to study material and lot of infotainment stuff. Stay Connected!!

VUDESk ALL Subject CODES
Find Your Subject Code , Join Group And You Will Get ALL related Data
ACC - Fundamentals of auditing and business
ACC311ACC501
ACF - (Accounting And Finance Related)
ACF619ACFI619
COM - (Commerce Related)
COM619COMI619
ECO - (Economics Related)
ECO401 ECO402 ECO403 ECO404
ENG - (English Related)
ENG001 ENG101 ENG201 ENG301 ENG401
ETH201 - Ethics (for Non-Muslims)
ETH201
ISL201 - Islamic Studies
ISL201
IT - (Info Tech Related
IT000IT0001IT430IT619ITI619
MIS - (Project And Internship Report)
MIS619 MISI619MIS620 MISI620
PAD - (Public Administration Related)
PAD619 PADI619
PAK301 - Pakistan Studies
PAK301PAK302
PHY - (Physics Related)
PHY101 PHY301
PSC201 - International Relations
PSC201PSC401
SOC - (Socialogy Related)
SOC101 SOC401
STA - (Statistics and Research)
STA301 STA630
URDU - (Urdu Related)
URD101

CS304_Midterm_Spring, 2012 (12-05-2012)

By Nadeempomy

 

Q.1

Identify which of the following overloaded operator function’s declaration is appropriate for the given call?

Rational_number_1 + 2.325 Where Rational_number_1 is an object of user defined class Rational_number.

 

► Rational_number operator+( Rational_number & obj);

► Rational_number operator+(double& obj); (Page 145)

► Rational_number operator+(Rational_number &obj, double& num);

► operator+(double& obj);

 

Q. 2

Which operator can not be overloaded?

 

► ::

► >>

► /p>

 

Q. 3

To convert from a user-defined class to a basic type, you would most likely use

 

► a built-in conversion operator.

► a one-argument constructor.

an overloaded = operator. (May be this one)

► a conversion operator that’s a member of the class. (May be this one)

 

Q. 4

A C++ class is similar to --------------------

 

Structure

► Header File

► Library File

► None of the given

 

Q. 5

A class can be identified from a statement by -------------

 

►Noun (Page 58)

►Pronoun

►Verb

►Adverb

 

Q. 6

 

Suppose there is an object of type Person, which of the following can be considered as one of its attributes

 

► Name

► Age

► Work()

► Both Name and Age (page 13)

 

Q. 7

Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2 to work correctly, if the overloaded - operator must

 

► take two arguments. (Doubted)

► return a value (Doubted)

► create a named temporary object.

► take four arguments

 

Q. 8

Using encapsulation we can achieve

 

► Information hiding, least interdependencies & implementation dependence

Inheritance, Information Hiding, Abstraction

► Information Hiding, Polymorphism, Abstraction

 

Q. 9

Abstraction is

 

 

Q. 10

 Abstract Class has

 

► Zero Instance

► One Instance

► Two Instance

Many Instance

 

Q. 11

If constructor in not initialized then

 

► Compiler will give error message

► Compiler will give warning

► Compiler will initialize zero by default

 

Q. 21   (2)

Differentiate Unary & Binary operators from the followings:

%, &, &&, *, --, =, /

 

Q. 22   (2)

What is “anonymous base class” object? Explain with example

 

Q. 23   (3)

Justify the statement “getter is the good programming practice”.

 

Q. 24   (3)

Give C++ code to overload assignment operator for string class

 

Q. 25   (5)

How we resolve the following problems in overloading of assignment operator in string class, (explain with the help of c++ code) Self referencing Assigning a string value to more than one strings in a single line like, stringobject1 = string object2 = stringobject3 = stringobject4

 

Ans.

Handout Page:150

class String{

public:

String & operator = (const String &);

 };

String & String :: operator = (const String & rhs){

size = rhs.size;

delete [] bufferPtr;

if(rhs.size != 0){

bufferPtr = new char[rhs.size+1];

strcpy(bufferPtr,rhs.bufferPtr);

}

else bufferPtr = NULL;

return *this;

}

 

Q. 26   (5)

Detect and correct compile time error(s) in the following code:

class Exam

{

char *ExamName;

int No_of_paper;

 

public:

Exam()

{

ExamName = "Final Term";

No_of_paper = 5;

}

 

void setname( char* name) const

{

ExamName = name;

}

void setpaper(int paper) const

{

No_of_paper = paper;

}

char* getname()

{

return ExamName;

}

int getpaper()

{

return No_of_paper;

}

};

 

int main()

{

const Exam exam1;

 

cout " Exam = "exam1.getname()endl;

cout " Numbe of paper = " exam1.getpaper();

 

getch();

return 0;

}

 

Answer:- Corrected Code

class Exam

{

char *ExamName;

int No_of_paper;

 

public:

Exam()

{

ExamName = "Final Term";

No_of_paper = 5;

}

void setname( char* name)

{

ExamName=name;

}

void setpaper(int paper)

{

No_of_paper = paper;

}

char* getname()

{

return ExamName;

}

int getpaper()

{

return No_of_paper;

}

};

 

int main()

{

Exam exam1;

 

cout " Exam = "exam1.getname()endl;

cout " Numbe of paper = " exam1.getpaper();

 

getch();

return 0;

}

Views: 37

Replies to This Discussion

Advertise Here

very nice keep it up 

RSS

*Member OF Week*

1. SiLeNt MooN(Admin)

SAHIWAL, Pakistan

=======================

Popular Social Events

=======================

+ Member of the Day

+ Member of the Week

+ Member of the Month

+ Member of the Year

+ Miss VU

+ Mr VU

+ Gold Members

+ Vote for Miss VU

+ Vote for Mr VU

+ Members Points Table

+ Profile Points Allocation

+ Competition Corner

+ Our Fans Club

+ Certificate Winners

---------------------------------------

௵ Scholars Of Desk

 Gold Members

 MR VU,S

௵ MISS VU,S

 Members Of Month

 Team Members

 Moderators 

  ADMINS

ʭAdministrationʭ

Senior Admin : Yasmeen

VUDESK Owner : Ismail Shah

DMCA.com

VUDESK GROUPS

© 2013   Created by ʭIsmail Shahʭ.

Badges  |  Report an Issue  |  Terms of Service

-->