Object Oriented Programming MCQs

Page No. 69

Which among the following is true for class exceptions?


aOnly base class can give rise to exceptions


bOnly derived class can give rise to exceptions


cEither base class or derived class may produce exceptions


d Both base class and derived class may produce exceptions



Which among the following is wrong syntax related to static data members?


aclassName :: staticDataMember;


bdataType className :: memberName =value;


cstatic dataType memberName;


dclassName : dataType -> memberName;



What will be the output of the following program? class Test { public: Test() { cout << "Test's Constructor is Called " << endl; } }; class Result { static Test a; public: Result() { cout << "Result's Constructor is Called " << endl; } }; void main() { Result b; }


aTest’s Constructor is Called


bResult’s Constructor is Called


c Result’s Constructor Called Test’s Constructor is Called


dTest’s Constructor Called Result’s Constructor is Called



If object of class are created, then the static data members can be accessed ____________


aUsing dot operator


bUsing arrow operator


cUsing colon


dUsing dot or arrow operator



Whenever any static data member is declared in a class ______________________


aOnly one copy of the data is created


bNew copy for each object is created


cNew memory location is allocated with each object


d Only one object uses the static data



What is the output of the following program? class Test { private: static int x; public: static void fun() { cout << ++x << “ ”; } }; int Test :: x =20; void main() { Test x; x.fun(); x.fun(); }


a20 22


b 20 21


c21 22


d22 23


View Answer 21 22

Which data members among the following are static by default?


aextern


binteger


cconst


dvoid


View Answer const

Which among the following is the correct syntax to access static data member without using member function?


aclassName -> staticDataMember;


bclassName :: staticDataMember;


cclassName : staticDataMember;


dclassName . staticDataMember;



The static data member __________________________


aCan be accessed directly


bCan be accessed with any public class name


cCan be accessed with dot operator


dCan be accessed using class name if not using static member function



If static data members have to be used inside a class, those member functions _______________


aMust not be static member functions


bMust not be member functions


cMust be static member functions


dMust not be member function of corresponding class



Goto Page No.

Page 69 of 93

Alphabetical MCQs Categories

Here below You find all kind of categories of MCQs in alphabetical order.


"Comprehensive Collection of MCQs: Alphabetically Organized by Subject"

"Discover an extensive collection of multiple-choice questions (MCQs) neatly categorized by subject from A to Z. This resource is designed for anyone eager to explore various topics in a straightforward and organized manner. Whether you're a student preparing for exams, an educator seeking supplementary materials, or simply curious about different subjects, this compilation offers a convenient way to learn and assess your knowledge. With questions arranged alphabetically, navigation is effortless, allowing you to delve into subjects of interest at your own pace. Engage, learn, and expand your understanding with this accessible and comprehensive repository of MCQs!"


BolPakistan

bolpakistan.com.pk includes Job Mcqs and Pak Mcqs is the Top Largest Mcqs Forum in World, in which you can read Mcqs of All Subjects, PPSC test preparation, FPSC, NTS and PPSC PAST PAPERS, PPSC PAST MCQS. A Collection of Repeated MCQs for JOBs seekers.

Copyright © 2024, Designed & Developed by BolPakistan