WordPress.com



Id1QuestionWhat does the following statement mean??int (*fp)(char*)Apointer to a pointerBpointer to an array of charsCpointer to function taking a char* argument and returns an intDfunction taking a char* argument and returning a pointer to intAnswerCMarks1UnitIIIId2QuestionThe operator used for dereferencing or indirection is ____A*B&C->D–>>AnswerAMarks1UnitIIIId3QuestionChoose the right option????string* x, y;Ax is a pointer to a string, y is a stringBy is a pointer to a string, x is a stringCboth x and y are pointer to string typesDnone of the mentionedAnswerAMarks1UnitIIIId4QuestionWhich one of the following is not a possible state for a pointer?Ahold the address of the specific objectBpoint one past the end of an objectCZeroDpoint to a byteAnswerDMarks1UnitIIIId5QuestionWhich of the following is illegal?Aint *ip;Bstring s, *sp = 0;Cint i; double* dp = &i;Dint *pi = 0;AnswerDMarks1UnitIIIId6Question #include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout <<arr[1]; return 0; }A10B15C20DRandom numberAnswerDMarks2UnitIIIId7QuestionThe correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer isAint **fun(float**, char**)Bint *fun(float*, char*)Cint ***fun(float*, char**)Dint ***fun(*float, **char)AnswerCMarks1UnitIIIId8Question #include <iostream> using namespace std; int main() { char arr[20]; int i; for(i = 0; i < 10; i++) *(arr + i) = 65 + i; *(arr + i) = '\0'; cout << arr; return(0); }AABCDEFGHIJBAAAAAAAAACJJJJJJJJJJJJDNoneAnswerAMarks2UnitIIIId9Question #include <iostream> using namespace std; int main() { char *ptr; char Str[] = "abcdefg"; ptr = Str; ptr += 5; cout << ptr; return 0; }AfgBcdefCdefgDabcdAnswerAMarks2UnitIIIId10QuestionWhich rule will not affect the friend function?Aprivate and protected members of a class cannot be accessed from outsideBprivate and protected member can be accessed anywhereCboth a &bDNoneAnswerAMarks1UnitIIIId11QuestionWhich keyword is used to declare the friend function?AFirendBfriend CClassfriendDmyfriendAnswerBMarks1UnitIII12Question #include <iostream> using namespace std; class Box { double width; public: friend void printWidth( Box box ); void setWidth( double wid ); }; void Box::setWidth( double wid ) { width = wid; } void printWidth( Box box ) { box.width = box.width * 2; cout << "Width of box : " << box.width << endl; } int main( ) { Box box; box.setWidth(10.0); printWidth( box ); return 0; }A40B5C10D20AnswerDMarks2UnitIIIId13QuestionPick out the correct statement.AA friend function may be a member of another class.BA friend function may not be a member of another class.CA friend function may or may not be a member of another class.DNone of the mentionedAnswerCMarks1UnitIIIId14QuestionWhere does keyword ‘friend’ should be placed?Afunction declarationBfunction definitionCmain functionDNoneAnswerAMarks1UnitId15Question #include <iostream> using namespace std; class sample { private: int a, b; public: void test() { a = 100; b = 200; } friend int compute(sample e1); }; int compute(sample e1) { return int(e1.a + e1.b) - 5; } int main() { sample e; e.test(); cout << compute(e); return 0; }A100B200C300D295AnswerDMarks2UnitId16Question #include <iostream> using namespace std; class base { int val1, val2; public: int get(){ val1 = 100; val2 = 300;} friend float mean(base ob); }; float mean(base ob) { return float(ob.val1 + ob.val2) / 2; } int main() { base obj; obj.get(); cout << mean(obj); return 0; }A200B150C100D300AnswerMarks2UnitId17QuestionTo which does the function pointer point to?AVariableBConstantsCFunctionDabsolute variablesAnswerCMarks1UnitId18QuestionWhat we will not do with function pointers?Aallocation of memoryBde-allocation of memoryCboth a &bDNoneAnswerCMarks1UnitId19Question #include <iostream> using namespace std; int add(int first, int second) { return first + second + 15; } int operation(int first, int second, int (*functocall)(int, int)) { return (*functocall)(first, second); } int main() { int a; int (*plus)(int, int) = add; a = operation(15, 10, plus); cout << a; return 0; }A25B36C40D45AnswerCMarks2UnitId20Question #include <iostream> using namespace std; void func(int x) { cout << x ; } int main() { void (*n)(int); n = &func; (*n)( 2 ); n( 2 ); return 0; }A2B21C22D20AnswerCMarks2Unit21Question #include <iostream> using namespace std; int n(char, int); int (*p) (char, int) = n; int main() { (*p)('d', 9); p(10, 9); return 0; } int n(char c, int i) { cout << c << i; return 0; }Ad9? ? ?9Bd9d9Cd9DCompile time errorAnswerAMarks2UnitId22Question #include <iostream> using namespace std; int func (int a, int b) { cout << a; cout << b; return 0; } int main(void) { int(*ptr)(char, int); ptr = func; func(2, 3); ptr(2, 3); return 0; }A2323B232C23DCompile time errorAnswerDMarks2UnitId23QuestionWhat are the mandatory part to present in function pointers?A&Breturn valuesCData typesDNoneAnswerCMarks1UnitId24QuestionWhat is meaning of following declaration?int(*ptr[5])();Aptr is pointer to function.Bptr is array of pointer to function.Cptr is pointer to such function which return type is array.Dptr is pointer to array of function.AnswerBMarks1UnitId25QuestionWhat is size of generic pointer in c?A0B1C2DNullAnswerCMarks1UnitId26QuestionVoid pointer can point to which type of objects?AIntBFloatCDoubleDAllAnswerDMarks1UnitId27QuestionWhat does the following statement mean?? ? ?int (*fp)(char*)Apointer to a pointerBpointer to an array of charsCpointer to function taking a char* argument and returns an intDfunction taking a char* argument and returning a pointer to intAnswerCMarks1UnitId28QuestionWhat is size of generic pointer in C++ (in 32-bit platform) ?A2B4C8D0AnswerBMarks1UnitId29Question #include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; }A15 18 21B21 21 21C24 24 24DCompile time errorAnswerBMarks2UnitId30Question #include <iostream> using namespace std; int main() { int i; char *arr[] = {"C", "C++", "Java", "VBA"}; char *(*ptr)[4] = &arr; cout << ++(*ptr)[2]; return 0; }AavaBjavaCc++DCompile time errorAnswerAMarks2UnitId31Question #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *p; return 0; }A4B5C6D7AnswerBMarks2UnitId32Question #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << arr; return 0; }A4B5CAddress of arrD7AnswerCMarks2UnitId33Question #include <iostream> using namespace std; int main () { int numbers[5]; int * p; p = numbers; *p = 10; p++; *p = 20; p = &numbers[2]; *p = 30; p = numbers + 3; *p = 40; p = numbers; *(p + 4) = 50; for (int n = 0; n < 5; n++) cout << numbers[n] << ","; return 0; }A10,20,30,40,50,B1020304050CCompile time errorDRuntime errorAnswerAMarks2UnitId34Question #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *arr + 9; return 0; }A12B5C13DErrorAnswerCMarks2UnitId35QuestionA void pointer cannot point to which of these?Amethods in c++Bclass member in c++Call of the mentionedDNoneAnswerDMarks1UnitId36Question #include <iostream> using namespace std; int func(void *Ptr); int main() { char *Str = "abcdefghij"; func(Str); return 0; } int func(void *Ptr) { cout << Ptr; return 0; }AabcdefghijBaddress of string “abcdefghij”CCompile timeDRun time errorAnswerBMarks2UnitId37Question #include <iostream> using namespace std; int main() { int *p; void *vp; if (vp == p); cout << "equal"; return 0; }AEqualBNo outputCCompile time errorDRun time errorAnswerAMarks2UnitIIIId38Question #include <iostream> using namespace std; int main() { int n = 5; void *p = &n; int *pi = static_cast<int*>(p); cout << *pi << endl; return 0; }A5B6CCompile time errorDRun time errorAnswerAMarks2UnitId39Question #include <iostream> using namespace std; int main() { int a = 5, c; void *p = &a; double b = 3.14; p = &b; c = a + b; cout << c << '\n' << p; return 0; }A8, memory addressB8.14Cmemory addressDNoneAnswerAMarks2UnitId40QuestionWhat we can’t do on a void pointer?Apointer arithemeticBpointer functionsCBoth DNoneAnswerAMarks2UnitId41QuestionWhich value we cannot assign to reference?AIntegerBFloatingCUnsigned DNullAnswerDMarks1UnitId42Question #include <iostream> using namespace std; int main() { int a = 9; int & aref = a; a++; cout << "The value of a is " << aref; return 0; }A9B10C11DErrorAnswerBMarks2UnitId43Question #include <iostream> using namespace std; void print (char * a) { cout << a << endl; } int main () { const char * a = "Hello world"; print(const_cast<char *> (a) ); return 0; }AHello worldBHelloCWorldDCompile time errorAnswerAMarks2UnitId44QuestionIdentify the correct sentence regarding inequality between reference and pointer.Awe can not create the array of reference.Bwe can create the Array of reference.Cwe can use reference to reference.DNoneAnswerAMarks1UnitId45QuestionWhich is used to tell the computer that where a pointer is pointing to?ADereferenceBReferenceCheap operationsDNoneAnswerAMarks1UnitId46Question #include <iostream> using namespace std; int main() { int x; int *p; x = 5; p = &x; cout << *p; return 0; }A5B10CMemory addressDNoneAnswerAMarks2UnitId47Question #include <iostream> using namespace std; int main() { int x = 9; int* p = &x; cout << sizeof(p); return 0; }A4B2CDepends on compilerDNoneAnswerCMarks2UnitId48Question #include <iostream> using namespace std; int main() { double arr[] = {5.0, 6.0, 7.0, 8.0}; double *p = (arr+2); cout << *p << endl; cout << arr << endl; cout << *(arr+3) << endl; cout << *(arr) << endl; cout << *arr+9 << endl; return 0; }A7????0xbf99fc98????8????5????14B7????8????0xbf99fc98????5????14C0xbf99fc98DNoneAnswerAMarks2UnitId49QuestionWhat does the dereference operator will return?Arvalue equivalent to the value at the pointer address.Blvalue equivalent to the value at the pointer address.Cit will return nothingDNoneAnswerBMarks2UnitId50QuestionWhich operator is used in pointer to member function?A.*B->*CBoth a &bDNoneAnswerCMarks2UnitId51Question #include <iostream> using namespace std; class Foo { public: Foo(int i = 0){ _i = i;} void f() { cout << "Executed"<<endl; } private: int _i; }; int main() { Foo *p = 0; p -> f(); }AExecutedBErrorCRun time errorDNoneAnswerAMarks2UnitId52QuestionWhich is the best design choice for using pointer to member function?AInterface BClassCStructureDNoneAnswerAMarks2UnitId53QuestionVirtual functions allow you toAcreate an array of type pointer-to-base class that can hold pointers to derived classes.Bcreate functions that can never be accessed.Cgroup objects of different classes so they can all be accessed by the same function code.Duse the same function call to execute member functions of objects from different classes.AnswerDMarks1UnitIIIId54QuestionA pointer to a base class can point to objects of a derived class.ATRUEBFALSECDAnswerAMarks1UnitIIIId55QuestionA pure virtual function is a virtual function thatAcauses its class to be abstract.Breturns nothing.Cis used in a base class.DA and CAnswerDMarks1UnitIIIId56QuestionAn abstract class is useful whenAno classes should be derived from it.Bthere are multiple paths from one derived class to o objects should be instantiated from it.Dyou want to defer the declaration of the class.AnswerCMarks1UnitIIIId57QuestionA friendfunction can access a class’s private data without being a member of the class.ATRUEBFALSECDAnswerAMarks1UnitIIIId58QuestionA friend function can be used toAmediate arguments between classes.Bincrease the versatility of an overloaded operator.Callow access to an unrelated class.DB and CAnswerDMarks1UnitIIIId59QuestionThe keyword friend appears inAthe class allowing access to another class.Bthe private section of a class.Cthe public section of a class.DAll of the aboveAnswerDMarks1UnitIIIId60QuestionA static functionAshould be called when an object is destroyed.Bis closely connected to an individual object of a an be called using the class name and function name.Dis used when a dummy object must be created.AnswerCMarks1UnitIIIId61QuestionAn assignment operator might be overloaded toAhelp keep track of the number of identical objects.Bassign a separate ID number to each object.Csignal when assignment takes place.DAll of the aboveAnswerDMarks1UnitIIIId62QuestionThe user must always define the operation of the copy constructor.ATRUEBFALSECDAnswerBMarks1UnitIIIId63QuestionThe operation of the assignment operator and that of the copy constructor areAsimilar, except that the copy constructor creates a new object.Bdifferent, except that they both copy member data.Cdifferent, except that they both create a new object.DA and BAnswerDMarks1UnitIIIId64QuestionA copy constructor could be defined to copy only part of an object’s data.ATRUEBFALSECDAnswerAMarks1UnitIIIId65QuestionThe lifetime of a variable that isAlocal to a member function coincides with the lifetime of the function.Bglobal coincides with the lifetime of a onstatic member data of an object coincides with the lifetime of the object.DA and CAnswerDMarks1UnitIIIId66QuestionThere is no problem with returning the value of a variable defined as local within a member function so long as it is returned by value.ATRUEBFALSECDAnswerAMarks1UnitIIIId67QuestionA copy constructor is invoked whenAa function returns by value.Ban argument is passed by value.CA and BDan argument is passed by reference.AnswerCMarks2UnitIIIId68QuestionWhat does the thispointer point to?AData member of the classBthe object of which the function using it is a memberCMember functionDBase classAnswerBMarks1UnitIIIId69QuestionA pointer isAthe address of a variable.Ban indication of the variable to be accessed next.Ca variable for storing addresses.Dthe data type of an address variable.AnswerCMarks1UnitIIIId70QuestionThe expression *testcan be said toArefer to the contents of test.Bdereference test.Crefer to the value of the variable pointed to by test.DAll of the aboveAnswerDMarks2UnitIIIId71QuestionA pointer to void can hold pointers to __________AintBfloatCcharDAny data typeAnswerDMarks1UnitIIIId72QuestionThe type of variable a pointer points to must be part of the pointer’s definition so thatAdata types don’t get mixed up when arithmetic is performed on them.Bpointers can be added to one another to access structure members.Cthe compiler can perform arithmetic correctly to access array elements.DA and CAnswerDMarks2UnitIIIId73QuestionThe first element in a string isAthe name of the string.Bthe first character in the string.Cthe length of the string.Dthe name of the array holding the string.AnswerbMarks1UnitIIIId74QuestionThe newoperatorAreturns a pointer to a variable.Bcreates a variable called new.Cobtains memory for a new variable.DA and CAnswerDMarks2UnitIIIId75QuestionDefinition for an array arrof 8 pointers that point to variables of type floatis A*float arr[8]Bfloat* arr[8];Cfloat pointer[8]Dint *ary[8]AnswerBMarks1UnitIIIId76QuestionThe delete operator returns ____________ to the operating system.AMemory that is no longer neededBPointerCObjectDClassAnswerAMarks1UnitIIIId77QuestionIn a linked listAeach link contains a pointer to the next link.Beach link contains data or a pointer to data.Cthe links are stored in an array.DA and BAnswerDMarks2UnitIIIId78QuestionIf you wanted to sort many large objects or structures, it would be most efficient toAplace them in an array and sort the array.Bplace pointers to them in an array and sort the array.Cplace them in a linked list and sort the linked list.Dplace references to them in an array and sort the array.AnswerBMarks1UnitIIIId79QuestionThe contents of two pointers that point to adjacent variables of type floatdiffer by _____A1 byteB2 bytesC3 bytesD4 bytesAnswerDMarks1UnitIIIId80QuestionWhich of the following is true about virtual functions in C++.AVirtual functions are functions that can be overridden in derived class with the same signature.BVirtual functions enable run-time polymorphism in a inheritance hierarchy.CIf a function is 'virtual'in the base class, the most-derived class's implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference. In non-virtual functions, the functions are called according to the type of reference or pointerDAll of the aboveAnswerDMarks1UnitIIIId81QuestionPredict the output of following C++ program.#include<iostream>using namespace std;class Base {public: Base() { cout<<"Constructor: Base"<<endl; } virtual ~Base() { cout<<"Destructor : Base"<<endl; }};class Derived: public Base {public: Derived() { cout<<"Constructor: Derived"<<endl; } ~Derived() { cout<<"Destructor : Derived"<<endl; }};int main() { Base *Var = new Derived(); delete Var; return 0;}AConstructor: BaseConstructor: DerivedDestructor : DerivedDestructor : BaseBConstructor: BaseConstructor: DerivedDestructor : BaseCConstructor: BaseConstructor: DerivedDestructor : DerivedDConstructor: DerivedDestructor : DerivedAnswerAMarks2UnitIIIId82QuestionPredict the output of following C++ program. Assume that there is no alignment and a typical implementation of virtual functions is done by the compiler.#include <iostream>using namespace std; class A{public: virtual void fun();}; class B{public: void fun();}; int main(){ int a = sizeof(A), b = sizeof(B); if (a == b) cout <<"a == b"; else if (a >b) cout <<"a >b"; else cout <<"a <b"; return 0;}Aa>bBa==bCa<bDCompiler errorAnswerAMarks2UnitIIIId83QuestionWhich of the following is FALSE about references in C++AA reference must be initialized when declaredBOnce a reference is created, it cannot be later made to reference another object; it cannot be resetCReferences cannot be NULLDReferences cannot refer to constant valueAnswerDMarks1UnitIIIId84Question#include <iostream>using namespace std; class A{public: virtual void fun() { cout <<"A::fun() "; }}; class B: public A{public: void fun() { cout <<"B::fun() "; }}; class C: public B{public: void fun() { cout <<"C::fun() "; }}; int main(){ B *bp = new C; bp->fun(); return 0;}Which function will be called by statements bp->fun();?AA::fun()BB::fun()CC::fun()DCompiler errorAnswerCMarks2UnitIIIId85QuestionWhich of the followings is/are automatically added to every class, if we do not write our own.ACopy ConstructorBAssignment OperatorCA constructor without any parameterDAll of the aboveAnswerDMarks2UnitIIId85QuestionWhat is the output of following program?#include<iostream>using namespace std;class Point { Point() { cout <<"Constructor called"; }}; int main(){ Point t1; return 0;}ACompiler ErrorBRuntime ErrorCConstructor calledDSegmentation FaultAnswerAMarks1UnitIIIId86QuestionWhat will be the output of following program?#include <iostream>using namespace std; class Test{public: Test() { cout <<"Hello from Test() "; }} a; int main(){ cout <<"Main Started "; return 0;}AMain StartedBMain Started Hello from Test()CHello from Test() Main StartedDCompiler Error: Global objects are not allowedAnswerCMarks2UnitIIId87QuestionWhich rule will not affect the friend functionAprivate &protected members of a class cannot be accessed from outsideBprivate &protected member can be accessed anywhereCboth a &bDnone of theseAnswerAMarks1UnitIIIId88Questionwhich keyword is used to declare the friend functionAFriendBClass FriendCMy friendDall aboveAnswerAMarks1UnitIIIId89Questionwhat is syntax of friend function?AFriend class1 Class2;BFriend class;CFriend classDnone of theseAnswerDMarks1UnitIIIId90Questionwhat is output of the program?#include<iostream>using namespace std;class Box{double width;public:friend void printWidth(Box box);void setWidth(double wid);};void Box::setWidth(double wid){width-=wid;}void printWidth(Box box){box.width=box.width*2;cout<<"Width of box :"<<box.width<<endl;}int main(){Box box;box.setWidth(10.0);printWidth(box);return 0;}A40B5C10D20AnswerDMarks1UnitIIIId91Questionpick out the correct statement.AA friend function may be member of another classBA friend function may not be member of another classCA friend function may or may not be member of another classDnone of theseAnswerCMarks1UnitIIIId92QuestionWhere does keyword 'friend' should be placed?AFunction declarationBFunction definitionCMain functionDnone of theseAnswerAMarks1UnitIIIId94QuestionWhich of the following type of class allows only one object of it to be created?AVirtual classBAbstract classCSingleton classDFriend classAnswerCMarks1Unit3Id95QuestionWhich of the following is not type of constructor?ACopy constructorBFriend constructorCDefault constructorDParameterized constructorAnswerBMarks1UnitIIIId96QuestionWhich of the following statement is correct?ABase class pointer cannot point to derived classBDerived class pointer cannot point to base classCPointer to derived class cannot be createdDPointer to base class cannot be createdAnswerBMarks1UnitIIIId97QuestionWhich of the following is not the member of class?AStatic functionBFriend functionCConst functionDVirtual functionAnswerBMarks1UnitIIIId98QuestionWhich of the following is not member of class?AData hidingBDynamic TypingCDynamic bindingDDynamic loadingAnswerCMarks1UnitIIIId99QuestionThe operator used for dereferencing or indirection is______________A*B&C->D->>AnswerDMarks1UnitIIIId100QuestionChoose the right optionstring* x, yAx is pointer to string, y is a stringBy is pointer to string , x is a stringCboth x &y are pointer to string typesDnone of theseAnswerAMarks1UnitIIIId101QuestionWhich one of the following is not a possible state for a pointer?Ahold the address of specific objectBpoint one past the end of an objectCZeroDpoint to tyeAnswerDMarks1Unit3Id102QuestionWhich of the following is illegal?Aint *ip;Bstring s, *sp=0;Cint i;double *dp=&i;Dint *pi=0;AnswerCMarks1Unit3Id103Questionwhat will happen in the code?int a=100,b=200;int *p=&a, *q=&b;p=q;Ab is assigned to aBp now points to bCa is assigned to bDq now points to aAnswerBMarks1UnitIIIId104Questionwhat is output of this program?#include<iostream>using namespace std;int main(){int a=5, b=10, c=15;int *arr[]= {&a, &b, &c};cout<<arr[1];return 0;}A5B10C15Dit will return some random numberAnswerDMarks1UnitIIIId105QuestionThe correct statement for a function that takes pointer to a float , a pointer to a ponter to a char &return a pointer to a integer isAint**fun(float**, char**)Bint *fun(float*, char*)Cint ***fun(float*, char**)Dint ***fun(*float, **char)AnswerCMarks1UnitIIIId106QuestionWhat is size of generic pointer in C++(in 32-bit platform)?A2B4C8D0AnswerBMarks1Unit3Id107QuestionWhat is the output of this program?#include<iostream>using namespace std;int main(){int a[2][4]={3,6,9,12,15,18,21,24};cout<<*(a[1] + 2)<<*(*(a+1)+2)<<2[1[a]];return 0;}A15 18 21B21 21 21C24 24 24Dcompile time errorAnswerBMarks1Unit3Id108QuestionVoid pointer can point to which type of objects?AIntBFloatCDoubleDall of aboveAnswerDMarks1Unit3Id109QuestionWhen does the void pointer can be dereferenced?Awhen it doesn't point to any valueBwhen it cast to another type of objectCusing delete keywordDnone of aboveAnswerBMarks1Unit3Id110QuestionThe pointer can point to any variable that is not declared with which of these?AConstBVolatileCboth a &bDStaticAnswerCMarks1Unit3Id111QuestionA void pointer can not point to which of these?Amethods in C++Bclass member in c++Cboth a &bDnone of theseAnswerBMarks1Unit3Id112Questionwhat we can’t do on void pointer?Apointer arithmeticBpointer functionsCboth a &bDnone of theseAnswerAMarks1Unit3Id113QuestionTo which does the function pointer point to?AVariableBConstantsCFunctionDabsolute variablesAnswerCMarks1Unit3Id114QuestionWhat we will not do with function pointers?AAllocation of memoryBDe-allocation of memoryCboth a &bDnone of theseAnswerCMarks1Unit3Id115QuestionWhich of the following can be passed in function pointers?AVariablesBdata typesCFunctionsDnone of theseAnswerCMarks1Unit3Id116QuestionWhich operators are used in free store?ANewBDeleteCboth a &bDnone of theseAnswerCMarks1Unit3Id117QuestionWhat type of class member is operator new?AStaticBDynamicCConstDSmartAnswerAMarks1Unit3Id118Questionlinked lists are not suitable to for the implementation of_______________Ainsertion sortBradix sortCpolynomial manipulationDbinary searchAnswerDMarks1Unit3Id119QuestionRun time polymorphism can be achieved with____________Avirtual base classBcontainer classCvirtual functionDa &cAnswerCMarks1Unit3Id120QuestionWhen a virtual function is redefine by the derived class, it is called______AOverloadingBOverridingCRewritingDall of the aboveAnswerAMarks1Unit3Id121QuestionAn abstract class is useful whenAno classes should be derived from it.Bthere are multiple paths from one derived class to o objects should be instantiated from it.Dyou want to defer the declaration of the class.AnswerCMarks1UnitIIIId122QuestionUse of virtual functions impliesAOverloadingBOverridingCStatic bindingDDynamic bindingAnswerDMarks1UnitIIIId123QuestionWhich of the following type casts will convert an Integer variable named amount to a Double type?A(double) amountB( int to double) amountC int to double(amount)Dint (amount) to doubleAnswerAMarks1UnitIIIId124QuestionPure virtual functions?AHave to be redefined in the inherited classBCannot have public access specificationCAre mandatory for a virtual classDNone of the aboveAnswerAMarks1UnitIIIId125QuestionA friend function to a class, C cannot access?APrivate data members and member functionsBPublic data members and member functionsCProtected data members and member functionsDThe data members of the derived class of CAnswerDMarks1UnitIIIId126QuestionThe function whose prototype is void getData(Item *thing); receivesA a pointer to a structureBa reference to a structureCa copy of a structureDNoneAnswerAMarks1UnitIIIId127QuestionThe keyword friend does not appear in?AThe class allowing access to another classBThe class desiring access to another classCThe private section of a classDThe public section of a classAnswerCMarks1UnitIIIId128QuestionWhat is the output of the following codechar symbol[3]={‘a’,‘b’,‘c’};for (int index=0; index<3; index++)cout <<symbol [index];Aa b cB“abc”CabcD‘abc’AnswerCMarks1UnitIIIId129QuestionPredict output of the following program#include<iostream>using namespace std;?class Base{public:????virtual void show() { cout<<" In Base \n"; }};?class Derived: public Base{public:????void show() { cout<<"In Derived \n"; }};?int main(void){????Base *bp = new Derived;????bp->show();?????Base &br = *bp;????br.show();?????return 0;}AIn Base In Base BIn Base In DerivedCIn DerivedIn DerivedDIn DerivedIn Base AnswerCMarks2UnitIIIId130QuestionOutput of following program #include<iostream>using namespace std;?class Base{public:????virtual void show() { cout<<" In Base \n"; }};?class Derived: public Base{public:????void show() { cout<<"In Derived \n"; }};?int main(void){????Base *bp, b;????Derived d;????bp = &d;????bp->show();????bp = &b;????bp->show();????return 0;}AIn Base In Base BIn Base In DerivedCIn DerivedIn DerivedDIn DerivedIn Base AnswerDMarks2UnitIIIId131QuestionWhich of the following is true about pure virtual functions? 1) Their implementation is not known in a class where they are declared. 2) If a class has a pure virtual function, then the class becomes abstract class and an instance of this class cannot be created.AOnly 1BOnly 2CBothDNoneAnswerCMarks1UnitIIIId132Question#include<iostream>using namespace std;?class Base{public:????virtual void show() = 0;};?int main(void){????Base b;????Base *bp;????return 0;}AThere are compiler errors in lines "Base b;" and "Base bp;"BThere is compiler error in line "Base b;"CThere is compiler error in line "Base bp;"DNo compilation error AnswerBMarks2UnitIIIId133QuestionPredict the output of following program. #include<iostream>using namespace std;class Base{public:????virtual void show() = 0;};?class Derived : public Base { };?int main(void){????Derived q;????return 0;}ACompiler Error: there cannot be an empty derived classBCompiler Error: Derived is abstractCNo compiler ErrorDNoneAnswerBMarks2UnitIIIId134Question#include<iostream>using namespace std;?class Base{public:????virtual void show() = 0;};?class Derived: public Base{public:????void show() { cout<<"In Derived \n"; }};?int main(void){????Derived d;????Base &br = d;????br.show();????return 0;}ACompiler Error in line "Base &br = d;"BEmpty outputCIn derived DNoneAnswerCMarks2UnitIIIId135QuestionCan a constructor be virtual? Will the following program compile? #include <iostream>using namespace std;class Base {public:??virtual Base() {}?? };int main() {???return 0;}AYesBNoCDAnswerBMarks2UnitIIIId136QuestionCan a destructor be virtual? Will the following program compile? #include <iostream>using namespace std;class Base {public:??virtual ~Base() {}?? };int main() {???return 0;}AYesBNoCDAnswerAMarks2UnitIIIId137QuestionPredict the output#include<iostream>using namespace std;class Base? {public:????Base()??? { cout<<"Constructor: Base"<<endl; }????virtual ~Base()?? { cout<<"Destructor : Base"<<endl; }};class Derived: public Base {public:????Derived()?? { cout<<"Constructor: Derived"<<endl; }????~Derived()? { cout<<"Destructor : Derived"<<endl; }};int main()? {????Base *Var = new Derived();????delete Var;????return 0;}AConstructor: BaseConstructor: DerivedDestructor : DerivedDestructor : BaseBConstructor: BaseConstructor: DerivedDestructor : BaseCConstructor: BaseConstructor: DerivedDestructor : DerivedDConstructor: DerivedDestructor : DerivedAnswerAMarks2UnitIIIId138QuestionCan static functions be virtual? Will the following program compile? #include<iostream>?using namespace std;??? ??class Test{???public:??????virtual static void fun()? { }};AYesBNoCDAnswerBMarks2UnitIIIId139QuestionPredict the output of following C++ program. Assume that there is no alignment and a typical implementation of virtual functions is done by the compiler. #include <iostream>using namespace std;?class A{public:????virtual void fun();};?class B{public:???void fun();};?int main(){????int a = sizeof(A), b = sizeof(B);????if (a == b) cout <<"a == b";????else if (a >b) cout <<"a >b";????else cout <<"a <b";????return 0;}Aa>bBa==bCa<bDCompile time errorAnswerAMarks2UnitIIIId140Question#include <iostream>using namespace std;??class A{public:????virtual void fun() { cout <<"A::fun() "; }};??class B: public A{public:???void fun() { cout <<"B::fun() "; }};??class C: public B{public:???void fun() { cout <<"C::fun() "; }};??int main(){????B *bp = new C;????bp->fun();????return 0;}Aa::fun()Bb::fun()Cc::fun()DNoneAnswerCMarks2UnitIIIId141QuestionPredict the output of following C++ program #include<iostream>using namespace std;?class Base{public:????virtual void show() { cout<<" In Base \n"; }};?class Derived: public Base{public:????void show() { cout<<"In Derived \n"; }};?int main(void){????Base *bp = new Derived;????bp->Base::show();? // Note the use of scope resolution here????return 0;}AIn Base BIn derivedCCompile time errorDRuntime errorAnswerAMarks2UnitIIIId142QuestionWhich of the following is true about this pointer?AIt is passed as a hidden argument to all function callsBIt is passed as a hidden argument to all non-static function callsCIt is passed as a hidden argument to all static functionsDNoneAnswerBMarks1UnitIIIId143QuestionWhat is the use of this pointer?AWhen local variable’s name is same as member’s name, we can access member using this pointer.BTo return reference to the calling objectCCan be used for chained function calls on an objectDAllAnswerDMarks1UnitIIIId144QuestionPredict the output of following C++ program. #include<iostream>using namespace std;?class Test{private:??int x;public:??Test(int x = 0) { this->x = x; }??void change(Test *t) { this = t; }??void print() { cout <<"x = " <<x <<endl; }};?int main(){??Test obj(5);??Test *ptr = new Test (10);??obj.change(ptr);??obj.print();??return 0;}AX=5BX=10CCompile time errorDRun time errorAnswerCMarks2UnitIIIId145QuestionA static data member is given a valueAWithin the class definitionB Outside the class definitionCWhen the program is exeutedDNeverAnswerDMarks1UnitIIIId146QuestionA function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________ACall by nameBCall by valueCCall by referenceDCall by value resultAnswerBMarks1UnitIIIId147QuestionA ……………. takes a reference to an object of the same class as itself as an argument.AReference constructorBCopy ConstructorCSelf ConstructorDNone of the aboveAnswerBMarks1UnitIIIId148QuestionAutomatic initialization of object is carried out using a special member function calledAFriendBCastingCReference ParameterDConstructorAnswerDMarks1UnitIIIId149QuestionWhich of the following condition is true for an object used as a function argument?i) A copy of the entire objects is passed to the function.ii) Only the address of the object is transferred to the function.AOnly iBOnly iiCBoth I &iiDNone AnswerCMarks1UnitIIIId150QuestionWhich of the following parameter passing mechanism is/are supported by C++ not CAPass by valueBPass by referenceCPass by value resultDAll of aboveAnswerBMarks1UnitIII ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download