switch(um) { case 1: int umber!1"# case $: cout<<umber<<endl# default: cout<<%&'' is (imple%# ) ) 1" *rror 1" &'' is simple &'' is simple $ What will be the output of the following code: #include<iostream.h> void main() { int um!1# int umber!"# switch(um) { case 1: int umber# umber!1"# case $: cout<<umber<<endl# default: cout<<%&'' is (imple%# ) ) o value will be displa+ed. &ompile time error 1" &'' is simple " &'' is simple , -redict the .utput : #include <iostream.h> union /older { int um# int um1# )# void main() { /older 0ar# 0ar.um!1""# 0ar.um1!1""""# cout<<0ar.um# ) *rror 1"" 1"""" 1arbage 0alue 2 What will be the output of the following : #include<iostream.h> void main() { char 3-tr# -tr!%Who 4m 5....66%# cout<<3-tr# ) Who 4m 57.66 1arbage 0alue 8un 9ime *rror W : ;riendship relation cannot be inherited. 9rue ;alse <epends on &ompiler. 5 don=t >now. ? 4 class can have at most one destructor. 9rue ;alse <epends on level of inheritance. 5 don=t >now @ (a+ the .utput #include <iostream.h> class &l { int um# public: &l(int)# void displa+()# )# &l::&l(int i) { um!i# ) void &l::displa+() { cout<<endl<<um# ) void main() { &l .bA(1")# &l .bA1# .bA.displa+()# .bA1.displa+()# ) 1" 1arbage 0alue 1" error 1" 1" B which of the following cannot be overloaded 6: :: . (dot) .3 6: and :: .3 and . (dot) 6: :: and . (dot) 4ll C What will be the output of the following #include <iostream.h> using namespace std# void main() { std::cout<<%/ello.%# ) /ello. &ompile time error. 8un time error. 5 don=t >now. 1" What will be the output of the following #include <iostream.h> class Dase { public: Dase(){ cout<<%EnDase%# ) )# class <erived1:public Dase { public: <erived1(){ cout<<%En<erived1%# ) )# class <erived$:public <erived1 { public: <erived$(){ cout<<%En<erived$%# ) void <isp(){cout<<%En<ispla+%#) )# void main() { <erived$ .bA# .bA.<isp()# ) Dase <erived1 <erived$ <ispla+ <erived$ <ispla+ <erived1 Dase <erived$ <erived1 Dase <ispla+ <ispla+ 11 .bAects of the same class share the values of FFFFFFFFFF while the+ maintain separate values for FFFFFFFFF. on (tatic variablesG (tatic variables (tatic variables Gon (tatic variables 1lobal variablesG (tatic variables (tatic variablesG 8egister variables. 1$ What will be the output of the following #include <iostream.h> class &H4(( { int i# &H4((() { ''i# ) public: void <isp(){ cout<<i#) )# void main() { &H4(( .bA# .bA.<isp()# ) 1 1arbage 0alue *rror " 1, What will be the output of the following : #include <iostream.h> struct Dase { public: void <isp(){cout<<%/elloG how are +ou....66%#) )# struct <erived1: private Dase { public: void <isp() { Dase b# b.<isp()# ) )# void main() { <erived1 <# <.<isp()# ) /elloG how are +ou....66 5=m fine. *rrorG because structures cannot be inherited. *rrorG since privatel+ inheritaed 12 9he siIe of a class with no data members and member functions is FFFFFF b+tes. 1 $ , 2 1: what will be the output of the following : #include <iostream.h> class 4 { int um# public : virtual void disp(){) )# void main() { 4 a# cout<<siIeof(a)# ) 1 $ 2 B 1? (a+ the .utput : #include <iostream.h> void f(int JK1Gint 3+1Gint I1) { K1 ! K1 ' 3+1# 3+1 ! I1# I1 ! B# ) void main () { int K!$G+!2GI!?# f (KG J+G I)# cout << K << + << I << endl# ) ?G2GB $G2G? $G2GB ?G?G? 1@ 9here cannot be a circular a) (ingl+ lin> list b) Lueue c) (tac> d) <oubl+ lin>ed list aGd b c d 1B what will be the output of the following : #include <iostream.h> void main() { int um!1"G um1!1""# const int 3-tr!Jum# -tr!Jum1# cout<<3-tr# ) 1" 1"" 4ddress of um1 *rror 1C Which of the following operators are used as both unar+ J binar+ operators6 1) ' $) '' ,) M 2) 3 :) J a) 1G2G: b) $G2G: c) 1G$G: d) $G,G: a b c d $" What is true about inline functions6 a) 5tNs a compulsion on the compiler to ma>e function inline b) 5tNs a reOuest to the compiler to ma>e the function inline c) 5tNs the indication to the compiler that the function is recursive d) 5tNs the indication to the compiler that the function is member function. a b c d $1 5f program file contains following codeP main( ) { ) a) -rogram will give compilation error b) -rogram will get compiledG but cant be converted into eKecutable file c) -rogram will give runtime error d) one of above a b c d $$ #include<iostream.h> void main( ) { int K!$"G +!,:# K!+'' ' K''# + ! ''+ ' ''K# cout<< K <<endl << +# ) a) :: :: b) :B C: c) :@ C2 d) :: C, a b c d $, #include <iostream.h> void main( ) { int um!"# char &h!1"# um!&h# cout<<um# ) " 1" &ompile time error 8un time error $2 9he five items:4GDG&G< and * are pushed in stac> the other starting from 4. 9he stac> is popped four items and each element is inserted in a Oueue. 9hen two elements are deleted from the Oueue and pushed bac> on the stac>. ow one item is popped from the stac>. 9he popped item is: a) 4 b) D c) & d) < a b c d $: #include <iostream.h> void main( ) { switch(,G$) { case 1:cout<<%one%# brea># case $:cout<<%two%# brea># case ,:cout<<%three%# brea># default :cout<<%3%# ) ) What is the output of the above code6 a) *rror b) two c) three d) 3 a b c d $? 4 cop+ &onstructor need not have a single formal parameter the formal parameter has to be the same t+pe of the class the formal parameter is reOuired to be a const reference should have atleast one formal parameter $@ What 5s true about 8eference variables6 4)8eference variables have to be initialised where the+ are declared D)o memor+ is allocated for reference variables &)4 class can have a reference variable as its data member <)8eference variable declared as a data member of a class can be initialised in the constructor bod+ a b c d $B What is true about main ( ) a) main cannot be overloaded b) 4ddress of main cannot be ta>en c) main function can be inline d) main function can be static a b c d $C Which of the following is false with respect to inheritance6 When a base class is privatel+ inheritedG public J protected members of the base class becomes private members of derived class. When a base class is publicl+ inheritedG public members of base class becomes public members of derived class. When a base class is privatel+ inheritedG private members of base class becomes public members of derived class. When a base class is privatel+ inheritedG private members of base class becomes protected members of derived class. ," Which member functions of a class cannot modif+ its obAect attributes a) ;riend functions b) -rivate member functions c) &onstant member functions d) (tatic member functions a b c d ,1 What is true about (trong &ontenment. (trong &ontenment is called &omposition -ointer pointing to other obAect. 5n (trong &ontenment one class contains the obAect of another class within itself. 5n (trong &ontenment class contains it=s obAect within itself. ,$ What is true about 5nterface 6 4) 5nterface is pure abstract class. D) 5nterface hides emplementation. &) 5nterface is a class whose at least one methods is pure virtual method <) 5nterface is a class whose all methods are pure virtual methods 4 D & < ,, Qain pilars of &'' are 4bstraction *ncapsulation -ol+morphism 5nheritance ,2 #include <iostream.h> class &-lus-lus { char 3-# int len# )# int main() { const int siIe!2# &-lus-lus 3-tr ! new &-lus-lusRsiIeS# cout << siIeof(3-tr)# ) (4ssume 0& compiler) a) 2 b) $ c) B d) 1B a b c d ,: 4 reference variable a) must be member of some class b) 1ets initialised with Iero b+ default c) Qust be initialised with some variable d) Qust be initialised with a pointer variable a b c d ,? Which one is correct6 a) namespace define a space T bloc> J assigns a name to it b) namespace elements can be accessed using scope resolution operator c) namespace elements can be accessed b+ Uusing U mechanism d) 4ll 1G$G, are correct statements a b c d ,@ When the function passes a parameter b+ reference: a) 5f the formal parameter changes Gthe actual parameter also changes b) 5f the formal parameter changes G the actual parameter does not change c) 5f the actual parameter changes Gthe formal parameter does not change d) 5f the actual parameter changes Gthe formal parameter also changes a b c d ,B (tate which of the following is true : a) ofstream class is used for reading from file b) ifstream class is used for reading from file c) fstream class is used for reading from file a b c d ,C which of the following mode is default for ifstream out in app ate 2" Luestion from ;iles and (treams which of the following is true for Qode Dits for open ;untion a) noreplace : error when opening if file does not alread+ eKists. b) noreplace : error when opening for output if file alread+ eKistsG unless %ate% or %app% is set c) out : open for reading (default for ifstream) d) out : .pen for writting (default for ofstream) a b c d
Learn Python Programming for Beginners: Best Step-by-Step Guide for Coding with Python, Great for Kids and Adults. Includes Practical Exercises on Data Analysis, Machine Learning and More.