SlideShare a Scribd company logo
1 of 41
1. Which header file is used with input and output operations of C in C++?
a) stdio.h
b) cstdio
c) iostream
d) none of the mentioned
Answer: b) cstdio
2. Which will be used with physical devices to interact from C++ program?
a) Programs
b) Library
c) Streams
d) None of the mentioned
Answer: c) Streams
3. How many indicators are available in c++?
a) 4
b) 3
c) 2
d) 1
Answer: b) 3
4. What is the benefit of c++ input and output over c input and output?
a) Type safety
b) Exception
c) Both Type safety & Exception
d) None of the mentioned
Answer: a) Type safety
5. Which of the following is not a fundamental type is not present in C but
present in C++?
a) int
b) float
c) bool
d) void
Answer: c) bool
6. Which of the following is C++ equivalent for scanf()?
a) cin
b) cout
c) print
d) input
Answer: a) cin
7. Which of the following is C++ equivalent for printf()?
a) cin
b) cout
c) print
d) input
Answer: b) cout
8. Which of the following is an exit-controlled loop?
a) for
b) while
c) do-while
d) all of the mentioned
Answer: c) do-while
9. Which of the following is an entry-controlled loop?
a) for
b) while
c) do-while
d) both while and for
Answer: d) both while and for
10. Which of the following is the scope resolution operator?
a) .
b) *
c) ::
d) ~
Answer: c) ::
11. What is the size of a character type in C and C++?
a) 4 and 1
b) 1 and 4
c) 1 and 1
d) 4 and 4
Answer: c) 1 and 1
12. Which of the following operator is used with this pointer to access
members of a class?
a) .
b) !
c) ->
d) ~
Answer: c) ->
13. What is the output of the following C++ code?
#include <iostream>
int main(int argc, char const *argv[])
{
cout<<"Hello World";
return 0;
}
a) Hellow World
b) Compile-time error
c) Run-time error
d) Segmentation fault
Answer: b) Compile-time error
14. Which of the following syntax can be used to use a member of a
namespace without including that namespace?
a) namespace::member
b) namespace->member
c) namespace.member
d) namespace~member
Answer: a) namespace::member
15. What is std in C++?
a) std is a standard class in C++
b) std is a standard namespace in C++
c) std is a standard header file in C++
d) std is a standard file reading header in C++
Answer: b) std is a standard namespace in C++
16. Which of the following is the correct syntax of including a user defined
header files in C++?
a) #include <userdefined.h>
b) #include <userdefined>
c) #include “userdefined”
d) #include [userdefined]
Answer: c) #include “userdefined”
17. Which of the following is a correct identifier in C++?
a) 7var_name
b) 7VARNAME
c) VAR_1234
d) $var_name
Answer: c) VAR_1234
18. Which of the following is called address operator?
a) *
b) &
c) _
d) %
Answer: b) &
19. Which of the following is used for comments in C++?
a) // comment
b) /* comment */
c) both // comment or /* comment */
d) // comment */
Answer: c) both // comment or /* comment */
20. What are the actual parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of a function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
Answer: a) Parameters with which functions are called
21. The data elements in the structure are also known as what?
a) objects
b) members
c) data
d) none of the mentioned
Answer: b) members
22. What will be used when terminating a structure?
a) :
b) }
c) ;
d) ;;
Answer: c) ;
23. What will happen when the structure is declared?
a) it will not allocate any memory
b) it will allocate the memory
c) it will be declared and initialized
d) none of the mentioned
Answer: a) it will not allocate any memory
24. The declaration of the structure is also called as?
a) structure creator
b) structure signifier
c) structure specifier
d) none of the mentioned
Answer: c) structure specifier
25. Which of the following is a properly defined structure?
a) struct {int a;}
b) struct a_struct {int a;}
c) struct a_struct int a;
d) struct a_struct {int a;};
Answer: d) struct a_struct {int a;};
26. Which of the following accesses a variable in structure *b?
a) b->var;
b) b.var;
c) b-var;
d) b>var;
Answer: a) b->var;
27. What is the output of this program?
1.#include <iostream>
2. #include <string.h>
3. using namespace std;
4. int main()
5. {
6. struct student
7. {
8. int num;
9. char name[25];
10. };
11. student stu;
12. stu.num = 123;
13. strcpy(stu.name, "John");
14. cout << stu.num << endl;
15. cout << stu.name << endl;
16. return 0;
17. }
a) 123-john
b) john-john
c) compile time error
d) none of the mentioned
Answer: a) 123-john
28. What is the output of this program?
1. #include <iostream>
2. using namespace std;
3. struct Time
4. {
5. int hours;
6. int minutes;
7. int seconds;
8. };
9. int toSeconds(Time now);
10. int main()
11. {
12. Time t;
13. t.hours = 5;
14. t.minutes = 30;
15. t.seconds = 45;
16. cout << "Total seconds: " << toSeconds(t) << endl;
17. return 0;
18. }
19. int toSeconds(Time now)
20. {
21. return 3600 * now.hours + 60 * now.minutes + now.se
conds;
22. }
a) 19845
b) 20000
c) 15000
d) 19844
Answer: a) 19845
29. What will be the output of this program?
1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5. struct ShoeType
6. {
7. string style;
8. double price;
9. };
10. ShoeType shoe1, shoe2;
11. shoe1.style = "Adidas";
12. shoe1.price = 9.99;
13. cout << shoe1.style << " $ "<< shoe1.price;
14. shoe2 = shoe1;
15. shoe2.price = shoe2.price / 9;
16. cout << shoe2.style << " $ "<< shoe2.price;
17. return 0;
18. }
a) Adidas $ 9.99Adidas $ 1.11
b) Adidas $ 9.99Adidas $ 9.11
c) Adidas $ 9.99Adidas $ 11.11
d) none of the mentioned
Answer: a) Adidas $ 9.99Adidas $ 1.11
30. What is the output of this program?
1.#include <iostream>
2. using namespace std;
3. struct sec
4. {
5. int a;
6. char b;
7. };
8. int main()
9. {
10. struct sec s ={25,50};
11. struct sec *ps =(struct sec *)&s;
12. cout << ps->a << ps->b;
13. return 0;
14. }
a) 252
b) 253
c) 254
d) 262
Answer: a) 252
31. Where does the execution of the program starts?
a) user-defined function
b) main function
c) void function
d) else function
Answer: b) main function
32. What are mandatory parts in the function declaration?
a) return type, function name
b) return type, function name, parameters
c) parameters, function name
d) parameters, variables
Answer: a) return type, function name
33. which of the following is used to terminate the function declaration?
a) :
b) )
c) ;
d) ]
Answer: c) ;
34. How many can max number of arguments present in function in the c99
compiler?
a) 99
b) 90
c) 102
d) 127
Answer: d) 127
35. Which is more effective while calling the functions?
a) call by value
b) call by reference
c) call by pointer
d) call by object
Answer: b) call by reference
36. What is the scope of the variable declared in the user defined function?
a) whole program
b) only inside the {} block
c) the main function
d) header section
Answer: b) only inside the {} block
37. How many minimum number of functions should be present in a C++ program
for its execution?
a) 0
b) 1
c) 2
d) 3
Answer: b) 1
38. Which of the following is the default return value of functions in C++?
a) int
b) char
c) float
d) void
Answer: a) int
39. What happens to a function defined inside a class without any complex
operations (like looping, a large number of lines, etc)?
a) It becomes a virtual function of the class
b) It becomes a default calling function of the class
c) It becomes an inline function of the class
d) The program gives an error
Answer: c) It becomes an inline function of the class
40. What is an inline function?
a) A function that is expanded at each call during execution
b) A function that is called during compile time
c) A function that is not checked for syntax errors
d) A function that is not checked for semantic analysis
Answer: a) A function that is expanded at each call during execution
41. An inline function is expanded during ______________
a) compile-time
b) run-time
c) never expanded
d) end of the program
Answer: b) run-time
42. In which of the following cases inline functions may not word?
i) If the function has static variables.
ii) If the function has global and register variables.
iii) If the function contains loops
iv) If the function is recursive
a) i, iv
b) iii, iv
c) ii, iii, iv
d) i, iii, iv
Answer: d) i, iii, iv
43. When we define the default values for a function?
a) When a function is defined
b) When a function is declared
c) When the scope of the function is over
d) When a function is called
Answer: b) When a function is declared
44. Where should default parameters appear in a function prototype?
a) To the rightmost side of the parameter list
b) To the leftmost side of the parameter list
c) Anywhere inside the parameter list
d) Middle of the parameter list
Answer: a) To the rightmost side of the parameter list
45. If an argument from the parameter list of a function is defined constant then
_______________
a) It can be modified inside the function
b) It cannot be modified inside the function
c) Error occurs
d) Segmentation fault
Answer: b) It cannot be modified inside the function
46. Which of the following feature is used in function overloading and function
with default argument?
a) Encapsulation
b) Polymorphism
c) Abstraction
d) Modularity
Answer: c) Abstraction
47. From which function the execution of a C++ program starts?
a) start() function
b) main() function
c) new() function
d) end() function
Answer: b) main() function
48. Which of the following is important in a function?
a) Return type
b) Function name
c) Both return type and function name
d) The return type, function name and parameter list
Answer: c) Both return type and function name
49. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y) { return (x+y); }
a) -5
b) 0
c) 10
d) 5
Answer: d) 5
50. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void square (int *x, int *y)
{
*x = (*x) * --(*y);
}
int main ( )
{
int number = 30;
square(&number, &number);
cout << number;
return 0;
}
a) 870
b) 30
c) Error
d) Segmentation fault
Answer: a) 870
51. What does a class in C++ holds?
a) data
b) functions
c) both data & functions
d) none of the mentioned
Answer: c) both data & functions
52. How many specifiers are present in access specifiers in class?
a) 1
b) 2
c) 3
d) 4
Answer: c) 3
53. Which is used to define the member of a class externally?
a) :
b) ::
c) #
d) none of the mentioned
Answer: b) ::
54. Which other keywords are also used to declare the class other than class?
a) struct
b) union
c) object
d) both struct & union
Answer: d) both struct & union
55. Which of the following is a valid class declaration?
a) class A { int x; };
b) class B { }
c) public class A { }
d) object A { int x; };
Answer: a) class A { int x; };
56. The data members and functions of a class in C++ are by default ____________
a) protected
b) private
c) public
d) none of the mentioned
Answer: b) private
57. Constructors are used to
a) initialize the objects
b) construct the data members
c) both initialize the objects & construct the data members
d) none of the mentioned
Answer: a) initialize the objects
58. When struct is used instead of the keyword class means, what will happen in
the program?
a) access is public by default
b) access is private by default
c) access is protected by default
d) none of the mentioned
Answer: a) access is public by default
59. Which category of data type a class belongs to?
a) Fundamental data type
b) Derived data type
c) User defined derived data type
d) Atomic data type
Answer: c) User defined derived data type
60. Which operator a pointer object of a class uses to access its data members
and member functions?
a) .
b) ->
c) :
d) ::
Answer: b) ->
61. How the objects are self-referenced in a member function of that class.
a) Using a special keyword object
b) Using this pointer
c) Using * with the name of that object
d) By passing self as a parameter in the member function
Answer: b) Using this pointer
62. What does a mutable member of a class mean?
a) A member that can never be changed
b) A member that can be updated only if it not a member of constant object
c) A member that can be updated even if it a member of constant object
d) A member that is global throughout the class
Answer: c) A member that can be updated even if it a member of constant
object
63. Pick the incorrect statement about inline functions in C++?
a) They reduce function call overheads
b) These functions are inserted/substituted at the point of call
c) Saves overhead of a return call from a function
d) They are generally very large and complicated function
Answer: d) They are generally very large and complicated function.
64. Inline functions are avoided when ____________________________
a) function contains static variables
b) function have recursive calls
c) function have loops
d) all of the mentioned
Answer: d) all of the mentioned
65. Which functions of a class are called inline functions?
a) All the functions containing declared inside the class
b) All functions defined inside or with the inline keyword
c) All the functions accessing static members of the class
d) All the functions that are defined outside the class
Answer: b) All functions defined inside or with the inline keyword
66. Where does the object is created?
a) class
b) constructor
c) destructor
d) attributes
Answer: a) class
67. How to access the object in the class?
a) scope resolution operator
b) ternary operator
c) direct member access operator
d) none of the mentioned
Answer: c) direct member access operator
68. Which of these following members are not accessed by using direct member
access operator?
a) public
b) private
c) protected
d) both private & protected
Answer: d) both private & protected
69. Pick out the other definition of objects.
a) member of the class
b) associate of the class
c) attribute of the class
d) instance of the class
Answer: d) instance of the class
70. How many objects can present in a single class?
a) 1
b) 2
c) 3
d) as many as possible
Answer: d) as many as possible
71. Where is the derived class is derived from?
a) derived
b) base
c) both derived & base
d) None of the mentioned
Answer: b) base
72. Pick out the correct statement.
a) A derived class’s constructor cannot explicitly invokes its base class’s constructor
b) A derived class’s destructor cannot invoke its base class’s destructor
c) A derived class’s destructor can invoke its base class’s destructor
d) None of the mentioned
Answer: b) A derived class’s destructor cannot invoke its base class’s
destructor
73. Which of the following can derived class inherit?
a) members
b) functions
c) both members & functions
d) none of the mentioned
Answer: c) both members & functions
74. Which class is used to design the base class?
a) abstract class
b) derived class
c) base class
d) none of the mentioned
Answer: a) abstract class
75. Which is used to create a pure virtual function?
a) $
b) =0
c) &
d) !
Answer: b) =0
76. Which is also called as abstract class?
a) virtual function
b) pure virtual function
c) derived class
d) none of the mentioned
Answer: b) pure virtual function
77. Where does the abstract class is used?
a) base class only
b) derived class
c) both derived & base class
d) none of the mentioned
Answer: a) base class only
78. Which special character is used to mark the end of class?
a) ;
b) :
c) #
d) $
Answer: a) ;
79. Which among the following is called first, automatically, whenever an object is
created?
a) Class
b) Constructor
c) New
d) Trigger
Answer: b) Constructor
80. Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
Answer: c) It must contain a definition body
81. Which among the following is correct?
a) class student{ public: int student(){} };
b) class student{ public: void student (){} };
c) class student{ public: student{}{} };
d) class student{ public: student(){} };
Answer: d) class student{ public: student(){} };
82. In which access should a constructor be defined, so that object of the class
can be created in any function?
a) Public
b) Protected
c) Private
d) Any access specifier will work
Answer: a) Public
83. How many types of constructors are available for use in general (with respect
to parameters)?
a) 2
b) 3
c) 4
d) 5
Answer: a) 2
84. How many types of constructors are available, in general, in any language?
a) 2
b) 3
c) 4
d) 5
Answer: b) 3
85. Choose the correct option for the following code.
86. class student
87. {
88. int marks;
89. }
90. student s1;
91. student s2=2;
a) Object s1 should be passed with argument.
b) Object s2 should not be declared
c) Object s2 will not be created, but program runs
d) Program gives compile time error
Answer: d) Program gives compile time error
92. Which constructor is called while assigning some object with another?
a) Default
b) Parameterized
c) Copy
d) Direct assignment is used
Answer: c) Copy
93. Which specifier applies only to the constructors?
a) Public
b) Protected
c) Implicit
d) Explicit
Answer: d) Explicit
94. Which among the following is true?
a) Default constructor can’t be defined by the programmer
b) Default parameters constructor isn’t equivalent to default constructor
c) Default constructor can be called explicitly
d) Default constructor is and always called implicitly only
Answer: c) Default constructor can be called explicitly
95. Which type of constructor can’t have a return type?
a) Default
b) Parameterized
c) Copy
d) Constructors don’t have a return type
Answer: d) Constructors don’t have a return type
96. Copy constructor is a constructor which ________________
a) Creates an object by copying values from any other object of same class
b) Creates an object by copying values from first object created for that class
c) Creates an object by copying values from another object of another class
d) Creates an object by initializing it with another previously created object of same
class
Answer: d) Creates an object by initializing it with another previously created
object of same class
97. The copy constructor can be used to:
a) Initialize one object from another object of same type
b) Initialize one object from another object of different type
c) Initialize more than one object from another object of same type at a time
d) Initialize all the objects of a class to another object of another class
Answer: a) Initialize one object from another object of same type
98. The copy constructors can be used to ________
a) Copy an object so that it can be passed to a class
b) Copy an object so that it can be passed to a function
c) Copy an object so that it can be passed to another primitive type variable
d) Copy an object for type casting
Answer: b) Copy an object so that it can be passed to a function
99. Which returning an object, we can use ____________
a) Default constructor
b) Zero argument constructor
c) Parameterized constructor
d) Copy constructor
Answer: d) Copy constructor
100. If a class implements some dynamic memory allocations and pointers
then _____________
a) Copy constructor must be defined
b) Copy constructor must not be defined
c) Copy constructor can’t be defined
d) Copy constructor will not be used
Answer: a) Copy constructor must be defined
101. What is the syntax of copy constructor?
a) classname (classname &obj){ /*constructor definition*/ }
b) classname (cont classname obj){ /*constructor definition*/ }
c) classname (cont classname &obj){ /*constructor definition*/ }
d) classname (cont &obj){ /*constructor definition*/ }
Answer: c) classname (cont classname &obj){ /*constructor definition*/ }
102. Which among the following best describes constructor overloading?
a) Defining one constructor in each class of a program
b) Defining more than one constructor in single class
c) Defining more than one constructor in single class with different signature
d) Defining destructor with each constructor
Answer: c) Defining more than one constructor in single class with different
signature
103. Can constructors be overloaded in derived class?
a) Yes, always
b) Yes, if derived class has no constructor
c) No, programmer can’t do it
d) No, never
Answer: d) No, never
104. Does constructor overloading include different return types for
constructors to be overloaded?
a) Yes, if return types are different, signature becomes different
b) Yes, because return types can differentiate two functions
c) No, return type can’t differentiate two functions
d) No, constructors doesn’t have any return type
Answer: d) No, constructors doesn’t have any return type
105. When is the constructor called for an object?
a) As soon as overloading is required
b) As soon as class is derived
c) As soon as class is created
d) As soon as object is created
Answer: d) As soon as object is created
106. Which among the following best describes destructor?
a) A function which is called just before the objects are destroyed
b) A function which is called after each reference to the object
c) A function which is called after termination of the program
d) A function which is called before calling any member function
Answer: a) A function which is called just before the objects are destroyed
107. Which among the following represents correct constructor?
a) ()classname
b) ~classname()
c) –classname()
d) classname()
Answer: d) classname()
108. Which among the following is correct syntax for the destructors?
a) classname()
b) ()classname
c) ~classname()
d) -classname()
Answer: c) ~classname()
109. Which among the following is correct for abstract class destructors?
a) It doesn’t have destructors
b) It has destructors
c) It may or may not have destructors
d) It contains an implicit destructor
Answer: a) It doesn’t have destructors
110. When is the destructor of a global object called?
a) Just before end of program
b) Just after end of program
c) With the end of program
d) Anytime when object is not needed
Answer: a) Just before end of program
111. Destructors doesn’t accept parameters.
a) True
b) False
Answer: a) True
112. Destructors can be ________
a) Abstract type
b) Virtual
c) Void
d) Any type depending on situation
Answer: b) Virtual
113. Global destructors execute in ___________ order after main function is
terminated
a) Sequential
b) Random
c) Reverse
d) Depending on priority
Answer: c) Reverse
114. Which among the following best describes the Inheritance?
a) Copying the code already written
b) Using the code already written once
c) Using already defined functions in programming language
d) Using the data and functions into derived segment
Answer: d) Using the data and functions into derived segment
115. How many basic types of inheritance are provided as OOP feature?
a) 4
b) 3
c) 2
d) 1
Answer: a) 4
116. Which among the following best defines single level inheritance?
a) A class inheriting a derived class
b) A class inheriting a base class
c) A class inheriting a nested class
d) A class which gets inherited by 2 classes
Answer: b) A class inheriting a base class
117. Which programming language doesn’t support multiple inheritance?
a) C++ and Java
b) C and C++
c) Java and SmallTalk
d) Java
Answer: d) Java
118. Which is the correct syntax of inheritance?
a) class derived_classname : base_classname{ /*define class body*/ };
b) class base_classname : derived_classname{ /*define class body*/ };
c) class derived_classname : access base_classname{ /*define class body*/ };
d) class base_classname :access derived_classname{ /*define class body*/ };
Answer: c) class derived_classname : access base_classname{ /*define class
body*/ };
119. Which type of inheritance leads to diamond problem?
a) Single level
b) Multi-level
c) Multiple
d) Hierarchical
Answer: c) Multiple
120. Members which are not intended to be inherited are declared as:
a) Public members
b) Protected members
c) Private members
d) Private or Protected members
Answer: c) Private members
121. The private members of the base class are visible in derived class but
are not accessible directly.
a) True
b) False
Answer: a) True
122. How can you make the private members inheritable?
a) By making their visibility mode as public only
b) By making their visibility mode as protected only
c) By making their visibility mode as private in derived class
d) It can be done both by making the visibility mode public or protected
Answer: d) It can be done both by making the visibility mode public or
protected
123. While inheriting a class, if no access mode is specified, then which
among the following is true? (in C++)
a) It gets inherited publicly by default
b) It gets inherited protected by default
c) It gets inherited privately by default
d) It is not possible
Answer: c) It gets inherited privately by default
124. How many types of inheritance are possible in C++?
a) 2
b) 3
c) 4
d) 5
Answer: d) 5
125. Which among the following best describes multiple inheritance?
a) Two classes being parent of any other classes
b) Three classes being parent of other classes
c) More than one class being parent of other child classes
d) More than one class being parent of single child
Answer: d) More than one class being parent of single child
126. How many types of inheritance can be used at a time in single
program?
a) Any two types
b) Any three types
c) Any 4 types
d) Any type, any number of times
Answer: d) Any type, any number of times
127. Which type of inheritance results in diamond problem?
a) Single level
b) Hybrid
c) Hierarchical
d) Multilevel
Answer: b) Hybrid
128. Which type of inheritance cannot involve private inheritance?
a) Single level
b) Multiple
c) Hybrid
d) All types can have private inheritance
Answer: d) All types can have private inheritance
129. Which among the following defines single level inheritance?
a) One base class derives another class
b) One derived class inherits from one base class
c) One base class inherits from one derived class
d) One derived class derives from another derived class
Answer: b) One derived class inherits from one base class
130. If class A and class B are derived from class C and class D, then
________________
a) Those are 2 pairs of single inheritance
b) That is multilevel inheritance
c) Those is enclosing class
d) Those are all independent classes
Answer: d ) Those are 2 pairs of single inheritance
131. If single inheritance is used, program will contain ________________
a) At least 2 classes
b) At most 2 classes
c) Exactly 2 classes
d) At most 4 classes
Answer: a) At least 2 classes
132. Single level inheritance supports _____________ inheritance.
a) Runtime
b) Compile time
c) Multiple inheritance
d) Language independency
Answer: a) Runtime
133. Which among the following is false for single level inheritance?
a) There can be more than 2 classes in program to implement single inheritance
b) There can be exactly 2 classes to implement single inheritance in a program
c) There can be more than 2 independent classes involved in single inheritance
d) The derived class must implement all the abstract method if single inheritance is
used
Answer: c) There can be more than 2 independent classes involved in single
inheritance
134. Single level inheritance will be best for___________
a) Inheriting a class which performs all the calculations
b) Inheriting a class which can print all the calculation results
c) Inheriting a class which can perform and print all calculations
d) Inheriting all the classes for different calculations
Answer: b) Inheriting a class which can print all the calculation results
135. Which among the following best defines multilevel inheritance?
a) A class derived from another derived class
b) Classes being derived from other derived classes
c) Continuing single level inheritance
d) Class which have more than one parent
Answer: b) Classes being derived from other derived classes
136. Multilevel inheritance allows _________________ in the program.
a) Only 7 levels of inheritance
b) At least 7 levels of inheritance
c) At most 16 levels of inheritance
d) As many levels of inheritance as required
Answer: d) As many levels of inheritance as required
137. What is minimum number of levels for a implementing multilevel
inheritance?
a) 1
b) 2
c) 3
d) 4
Answer: c) 3
138. In multilevel inheritance one class inherits _______________
a) Only one class
b) More than one class
c) At least one class
d) As many classes as required
Answer: a) Only one class
139. All the classes must have all the members declared private to
implement multilevel inheritance.
a) True
b) False
Answer: b) False
140. Multiple inheritance is ____________________
a) When a class is derived from another class
b) When a class is derived from two or more classes
c) When a class is derived from other two derived classes
d) When a class is derived from exactly one class
Answer: b) When a class is derived from two or more classes
141. Which problem arises due to multiple inheritance, if hierarchical
inheritance is used previously for its base classes?
a) Diamond
b) Circle
c) Triangle
d) Loop
Answer: a) Diamond
142. How many classes should a program contain to implement the multiple
inheritance?
a) Only 1
b) At least 1
c) At least 3
d) Exactly 3
Answer: c) At least 3
143. Why does diamond problem arise due to multiple inheritance?
a) Methods with same name creates ambiguity and conflict
b) Methods inherited from the superclass may conflict
c) Derived class gets overloaded with more than two class methods
d) Derived class can’t distinguish the owner class of any derived method
Answer: a) Methods with same name creates ambiguity and conflict
144. How many base classes can a derived class have which is implementing
multiple inheritance?
a) Only 2
b) At least 2
c) At most 2
d) As many as required
Answer: d
145. Which among the following is best to define hierarchical inheritance?
a) More than one classes being derived from one class
b) More than 2 classes being derived from single base class
c) At most 2 classes being derived from single base class
d) At most 1 class derived from another class
Answer: a) More than one classes being derived from one class
146. How many classes must be there to implement hierarchical inheritance
?
a) Exactly 3
b) At least 3
c) At most 3
d) At least 1
Answer: b) At least 3
147. How many classes can be derived from the base class using
hierarchical inheritance?
a) As many as required
b) Only 7
c) Only 3
d) Up to 127
Answer: a) As many as required
148. How many types of inheritance should be used for hybrid ?
a) Only 1
b) At least 2
c) At most two
d) Always more than 2
Answer: b) At least 2
149. Which type of inheritance must be used so that the resultant is hybrid?
a) Multiple
b) Hierarchical
c) Multilevel
d) None
Answer: d) None
150. What is the maximum number of classes allowed in hybrid inheritance?
a) 7
b) 127
c) 255
d) As many as required
Answer: d) As many as required
151. Which among the following best describes polymorphism?
a) It is the ability for a message/data to be processed in more than one form
b) It is the ability for a message/data to be processed in only 1 form
c) It is the ability for many messages/data to be processed in one way
d) It is the ability for undefined message/data to be processed in at least one way
Answer: a) It is the ability for a message/data to be processed in more than one
form
152. What do you call the languages that support classes but not
polymorphism?
a) Class based language
b) Procedure Oriented language
c) Object-based language
d) If classes are supported, polymorphism will always be supported
Answer: c) Object-based language
153. Which among the following is the language which supports classes but
not polymorphism?
a) SmallTalk
b) Java
c) C++
d) Ada
Answer: d) Ada
154. If same message is passed to objects of several different classes and
all of those can respond in a different way, what is this feature called?
a) Inheritance
b) Overloading
c) Polymorphism
d) Overriding
Answer: c) Polymorphism
155. Which class/set of classes can illustrate polymorphism in the following
code:
abstract class student
{
public : int marks;
calc_grade();
}
class topper:public student
{
public : calc_grade()
{
return 10;
}
};
class average:public student
{
public : calc_grade()
{
return 20;
}
};
class failed{ int marks; };
a) Only class student can show polymorphism
b) Only class student and topper together can show polymorphism
c) All class student, topper and average together can show polymorphism
d) Class failed should also inherit class student for this code to work for polymorphism
Answer: c) All class student, topper and average together can show polymorphism
156. Which type of function among the following shows polymorphism?
a) Inline function
b) Virtual function
c) Undefined functions
d) Class member functions
Answer: b) Virtual function
157. In case of using abstract class or function overloading, which function
is supposed to be called first?
a) Local function
b) Function with highest priority in compiler
c) Global function
d) Function with lowest priority because it might have been halted since long time,
because of low priority
Answer: b) Function with highest priority in compiler
158. Which among the following can’t be used for polymorphism?
a) Static member functions
b) Member functions overloading
c) Predefined operator overloading
d) Constructor overloading
Answer: a) Static member functions
159. What is output of the following program?
class student
{
public : int marks;
void disp()
{
cout<<”its base class”
};
class topper:public student
{
public :
void disp()
{
cout<<”Its derived class”;
}
}
void main() { student s; topper t;
s.disp();
t.disp();
}
a)Its base classIts derived class
b) Its base class Its derived class
c) Its derived classIts base class
d) Its derived class Its base class
Answer: a) Its base classIts derived class
160. Which among the following can show polymorphism?
a) Overloading ||
b) Overloading +=
c) Overloading <<
d) Overloading &&
Answer: c) Overloading <<
161. Find the output of the program:
class education
{
char name[10];
public : disp()
{
cout<<”Its education system”;
}
class school:public education
{
public: void dsip()
{
cout<<”Its school education system”;
}
};
void main()
{
school s;
s.disp();
}
}
a) Its school education system
b) Its education system
c) Its school education systemIts education system
d) Its education systemIts school education system
Answer: a) Its school education system
162. Polymorphism is possible in C language.
a) True
b) False
Answer: a) True
163. Which problem may arise if we use abstract class functions for
polymorphism?
a) All classes are converted as abstract class
b) Derived class must be of abstract type
c) All the derived classes must implement the undefined functions
d) Derived classes can’t redefine the function
Answer: c) All the derived classes must implement the undefined functions
164. Which among the following is not true for polymorphism?
a) It is feature of OOP
b) Ease in readability of program
c) Helps in redefining the same functionality
d) Increases overhead of function definition always
Answer: d) Increases overhead of function definition always
165. If 2 classes derive one base class and redefine a function of base class,
also overload some operators inside class body. Among these two things of
function and operator overloading, where is polymorphism used?
a) Function overloading only
b) Operator overloading only
c) Both of these are using polymorphism
d) Either function overloading or operator overloading because polymorphism can be
applied only once in a program
Answer: d) Either function overloading or operator overloading because
polymorphism can be applied only once in a program
166. Which header file is required to use file I/O operations?
a) <ifstream>
b) <ostream>
c) <fstream>
d) <iostream>
Answer: c) <fstream>
167. Which of the following is used to create an output stream?
a) ofstream
b) ifstream
c) iostream
d) fsstream
Answer: a) ofstream
168. Which of the following is used to create a stream that performs both
input and output operations?
a) ofstream
b) ifstream
c) iostream
d) fstream
Answer: d) fstream
169. Which of the following is not used as a file opening mode?
a) ios::trunc
b) ios::binary
c) ios::in
d) ios::ate
Answer: a) ios::trunc
170. Which of the following statements are correct?
1) It is not possible to combine two or more file opening mode in open()
method.
2) It is possible to combine two or more file opening mode in open() method.
3) ios::in and ios::out are input and output file opening mode respectively.
a) 1, 3
b) 2, 3
c) 3 only
d) 1, 2
Answer: a) 1, 3
171. By default, all the files in C++ are opened in _________ mode.
a) Text
b) Binary
c) ISCII
d) VTC
Answer: a) Text
172. What is the use of ios::trunc mode?
a) To open a file in input mode
b) To open a file in output mode
c) To truncate an existing file to half
d) To truncate an existing file to zero
Answer: d) To truncate an existing file to zero
173. Which of the following is the default mode of the opening using the
ofstream class?
a) ios::in
b) ios::out
c) ios::app
d) ios::trunk
Answer: b) ios::out
174. What is the return type open() method?
a) int
b) char
c) bool
d) float
Answer: c) bool
175. Which of the following is not used to seek file pointer?
a) ios::set
b) ios::end
c) ios::cur
d) ios::beg
Answer: a) ios::set
176. Which of the following is the default mode of the opening using the
ifstream class?
a) ios::in
b) ios::out
c) ios::app
d) ios::trunk
Answer: a) ios::in
177. Which of the following is the default mode of the opening using the
fstream class?
a) ios::in
b) ios::out
c) ios::in|ios::out
d) ios::trunk
Answer: c) ios::in|ios::out
178. Which function is used in C++ to get the current position of file pointer
in a file?
a) tell_p()
b) get_pos()
c) get_p()
d) tell_pos()
Answer: a) tell_p()
179. Which function is used to reposition the file pointer?
a) moveg()
b) seekg()
c) changep()
d) go_p()
Answer: b) seekg()
180. Which of the following is used to move the file pointer to start of a file?
a) ios::beg
b) ios::start
c) ios::cur
d) ios::first
Answer: a) ios::beg
181. What is the use of IO class?
a) To handle all the input operations
b) To handle all the output operations
c) To handle all the input and output operations
d) To handle all the input and output to the standard input
Answer: c) To handle all the input and output operations
182. IO class provides input and output through ______________________
a) Data streams
b) Serialization
c) File system
d) Data streams, serialization and file system
Answer: d) Data streams, serialization and file system
183. Which among the following class contains the methods to access
character based console device?
a) Console
b) File
c) Device
d) Pipe
Answer: a) Console
184. File class is ____________________________
a) An abstract of file representation only
b) An abstract of path names only
c) An abstract which can be used to represent path names or file
d) An abstract which can represent a file in any format
Answer: c) An abstract which can be used to represent path names or file
185. What is a File Descriptor?
a) A handle for machine specific structure of an open file
b) A handle for program specific structure of an open file
c) A handle for compiler specific structure of an open file
d) A handle for representing device files structure
Answer: a) A handle for machine specific structure of an open file
186. File Input Stream _________________________
a) Gets the input stream from any device file
b) Gets the input stream from any open socket
c) Gets the input stream from any cache
d) Gets the input stream from any open file only
Answer: d) Gets the input stream from any open file only
187. What does File Permission class do?
a) This class is used to give permission rights to a file
b) This class is used to restrict use of permissions
c) This class is used to represent device access permissions
d) This class is used to represent file access permissions
Answer: d) This class is used to represent file access permissions
188. Which class among the following makes incorrect assumptions?
a) Line Number Input Stream
b) Line Number Reader
c) Line Reader
d) Line Buffer
Answer: a) Line Number Input Stream
189. Reader class is _________________
a) Used to read from files
b) Abstract class to read character streams
c) Abstract class to input character streams
d) Used to take input from standard input stream
Answer: b) Abstract class to read character streams
190. Which class can handle IO class interrupt?
a) ExceptionIO
b) InteruptedIO
c) InteruptedIOException
d) IOInteruptException
Answer: c) InteruptedIOException
191. String Reader handles _____________________
a) Any character stream
b) A character stream whose source is an array
c) A character stream whose source is character array
d) A character stream whose source is String only
Answer: d) A character stream whose source is String only
192. Which exception handler can be used when character encoding is not
supported?
a) UnsupportedException
b) UnsupportedEncodingException
c) SupportException
d) EncodingException
Answer: b) UnsupportedEncodingException
193. PushBackReader allows the streams to be pushed back to the stream.
a) True
b) False
Answer: a) True
194. RandomAccessFile can be used to _______________________
a) Read from a random access file
b) Write to a random access file
c) Read and write to a random access file
d) Restricts read and write to a random access file
Answer: c) Read and write to a random access file
195. Which among the following is a serialization descriptor for any class?
a) StreamClass
b) ObjectStreamClass
c) ObjectStream
d) StreamObjectClass
Answer: b) ObjectStreamClass
196. What is the output of the following program?
1. #include <iostream>
2. using namespace std;
3. class Box
4. {
5. public :
6. double length;
7. double breadth;
8. double height;
9. };
10. int main( )
11. {
12. Box Box1;
13. double volume;
14. Box1.height = 5;
15. Box1.length = 6;
16. Box1.breadth = 7.1;
17. volume = Box1.height * Box1.length * Box1.breadth;
18. cout << "Volume of Box1 : " << volume <<endl;
19. return 0;
20. }
a)210
b)213
c)215
d) 217
Answer: b)213
197. What is the output of this program?
1. #include <iostream>
2. using namespace std;
3. class rect
4. {
5. int x, y;
6. public:
7. void val (int, int);
8. int area ()
9. {
10. return (x * y);
11. }
12. };
13. void rect::val (int a, int b)
14. {
15. x = a;
16. y = b;
17. }
18. int main ()
19. {
20. rect rect;
21. rect.val (3, 4);
22. cout << "rect area: " << rect.area();
23. return 0;
24. }
a) rect area: 24
b) rect area: 12
c) compile error because rect is as used as class name and variable name in line #20
d) none of the mentioned
Answer: b) rect area: 12
198. What is the correct syntax of accessing a static member of a Class?
---------------------------
Example class:
class A
{
public:
static int value;
}
---------------------------
a) A.value
b) A::value
c) A->value
d) A^value
Answer: b) A::value
199. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class S
{
int m;
public:
#define MAC(S::m)
};
int main(int argc, char const *argv[])
{
cout<<"Hello World";
return 0;
}
a) Hello World
b) Error
c) Segmentation Fault
d) Blank Space
Answer: b) Error
200. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
static int a;
public:
void change(int i){
a = i;
}
void value_of_a(){
cout<<a;
}
};
int main(int argc, char const *argv[])
{
A a1 = A();
a1.change(5);
a1.value_of_a();
return 0;
}
a) 5
b) Garbage value
c) Error
d) Segmentation fault
Answer: c) Error

More Related Content

What's hot

What's hot (20)

Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
C functions
C functionsC functions
C functions
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
Oops Quiz
Oops QuizOops Quiz
Oops Quiz
 
PART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQPART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQ
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented Programming
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Abstract method
Abstract methodAbstract method
Abstract method
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 

Similar to 200 mcq c++(Ankit dubey)

UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2Knowledge Center Computer
 
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1 UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1 Knowledge Center Computer
 
Java questions1
Java questions1Java questions1
Java questions1yash4884
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfVedant Gavhane
 
C aptitude 1st jan 2012
C aptitude 1st jan 2012C aptitude 1st jan 2012
C aptitude 1st jan 2012Kishor Parkhe
 
this pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming studentsthis pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming studentspavan81088
 
Model question paper_mc0061
Model question paper_mc0061Model question paper_mc0061
Model question paper_mc0061gurbaxrawat
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceAbishek Purushothaman
 
Data structures and algorithms unit i
Data structures and algorithms unit iData structures and algorithms unit i
Data structures and algorithms unit isonalisraisoni
 
Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)Poonam Chopra
 
C mcq practice test 4
C mcq practice test 4C mcq practice test 4
C mcq practice test 4Aman Kamboj
 
Java Questioner for
Java Questioner for Java Questioner for
Java Questioner for Abhay Korat
 
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice PaperCAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice PaperAlex Stewart
 

Similar to 200 mcq c++(Ankit dubey) (20)

UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ  Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ
 
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1 UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 1
 
Java questions1
Java questions1Java questions1
Java questions1
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
C aptitude 1st jan 2012
C aptitude 1st jan 2012C aptitude 1st jan 2012
C aptitude 1st jan 2012
 
this pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming studentsthis pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming students
 
Model question paper_mc0061
Model question paper_mc0061Model question paper_mc0061
Model question paper_mc0061
 
C MCQ
C MCQC MCQ
C MCQ
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
 
Data structures and algorithms unit i
Data structures and algorithms unit iData structures and algorithms unit i
Data structures and algorithms unit i
 
Technical questions
Technical questionsTechnical questions
Technical questions
 
Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)Sample Paper 2 Class XI (Computer Science)
Sample Paper 2 Class XI (Computer Science)
 
C mcq practice test 4
C mcq practice test 4C mcq practice test 4
C mcq practice test 4
 
Java Questioner for
Java Questioner for Java Questioner for
Java Questioner for
 
Gate-Cs 1994
Gate-Cs 1994Gate-Cs 1994
Gate-Cs 1994
 
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice PaperCAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
 
C question bank
C question bankC question bank
C question bank
 

More from Ankit Dubey

Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}Ankit Dubey
 
Ch5 cpu-scheduling
Ch5 cpu-schedulingCh5 cpu-scheduling
Ch5 cpu-schedulingAnkit Dubey
 
Ch2 system structure
Ch2 system structureCh2 system structure
Ch2 system structureAnkit Dubey
 
Ch1 introduction-to-os
Ch1 introduction-to-osCh1 introduction-to-os
Ch1 introduction-to-osAnkit Dubey
 
Mongodb mock test_ii
Mongodb mock test_iiMongodb mock test_ii
Mongodb mock test_iiAnkit Dubey
 
Android mock test_iii
Android mock test_iiiAndroid mock test_iii
Android mock test_iiiAnkit Dubey
 
Android mock test_ii
Android mock test_iiAndroid mock test_ii
Android mock test_iiAnkit Dubey
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06Ankit Dubey
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05Ankit Dubey
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04Ankit Dubey
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03Ankit Dubey
 

More from Ankit Dubey (20)

Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}
 
Scheduling
Scheduling Scheduling
Scheduling
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Ch5 cpu-scheduling
Ch5 cpu-schedulingCh5 cpu-scheduling
Ch5 cpu-scheduling
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
 
Ch3 processes
Ch3 processesCh3 processes
Ch3 processes
 
Ch2 system structure
Ch2 system structureCh2 system structure
Ch2 system structure
 
Ch1 introduction-to-os
Ch1 introduction-to-osCh1 introduction-to-os
Ch1 introduction-to-os
 
Android i
Android iAndroid i
Android i
 
Mongodb mock test_ii
Mongodb mock test_iiMongodb mock test_ii
Mongodb mock test_ii
 
Android mock test_iii
Android mock test_iiiAndroid mock test_iii
Android mock test_iii
 
Android mock test_ii
Android mock test_iiAndroid mock test_ii
Android mock test_ii
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 

Recently uploaded

Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 

200 mcq c++(Ankit dubey)

  • 1. 1. Which header file is used with input and output operations of C in C++? a) stdio.h b) cstdio c) iostream d) none of the mentioned Answer: b) cstdio 2. Which will be used with physical devices to interact from C++ program? a) Programs b) Library c) Streams d) None of the mentioned Answer: c) Streams 3. How many indicators are available in c++? a) 4 b) 3 c) 2 d) 1 Answer: b) 3 4. What is the benefit of c++ input and output over c input and output? a) Type safety b) Exception c) Both Type safety & Exception d) None of the mentioned Answer: a) Type safety 5. Which of the following is not a fundamental type is not present in C but present in C++? a) int b) float c) bool d) void Answer: c) bool 6. Which of the following is C++ equivalent for scanf()? a) cin b) cout c) print d) input
  • 2. Answer: a) cin 7. Which of the following is C++ equivalent for printf()? a) cin b) cout c) print d) input Answer: b) cout 8. Which of the following is an exit-controlled loop? a) for b) while c) do-while d) all of the mentioned Answer: c) do-while 9. Which of the following is an entry-controlled loop? a) for b) while c) do-while d) both while and for Answer: d) both while and for 10. Which of the following is the scope resolution operator? a) . b) * c) :: d) ~ Answer: c) :: 11. What is the size of a character type in C and C++? a) 4 and 1 b) 1 and 4 c) 1 and 1 d) 4 and 4 Answer: c) 1 and 1 12. Which of the following operator is used with this pointer to access members of a class? a) . b) ! c) -> d) ~
  • 3. Answer: c) -> 13. What is the output of the following C++ code? #include <iostream> int main(int argc, char const *argv[]) { cout<<"Hello World"; return 0; } a) Hellow World b) Compile-time error c) Run-time error d) Segmentation fault Answer: b) Compile-time error 14. Which of the following syntax can be used to use a member of a namespace without including that namespace? a) namespace::member b) namespace->member c) namespace.member d) namespace~member Answer: a) namespace::member 15. What is std in C++? a) std is a standard class in C++ b) std is a standard namespace in C++ c) std is a standard header file in C++ d) std is a standard file reading header in C++ Answer: b) std is a standard namespace in C++ 16. Which of the following is the correct syntax of including a user defined header files in C++? a) #include <userdefined.h> b) #include <userdefined> c) #include “userdefined” d) #include [userdefined]
  • 4. Answer: c) #include “userdefined” 17. Which of the following is a correct identifier in C++? a) 7var_name b) 7VARNAME c) VAR_1234 d) $var_name Answer: c) VAR_1234 18. Which of the following is called address operator? a) * b) & c) _ d) % Answer: b) & 19. Which of the following is used for comments in C++? a) // comment b) /* comment */ c) both // comment or /* comment */ d) // comment */ Answer: c) both // comment or /* comment */ 20. What are the actual parameters in C++? a) Parameters with which functions are called b) Parameters which are used in the definition of a function c) Variables other than passed parameters in a function d) Variables that are never used in the function Answer: a) Parameters with which functions are called 21. The data elements in the structure are also known as what? a) objects b) members c) data d) none of the mentioned Answer: b) members 22. What will be used when terminating a structure? a) : b) } c) ; d) ;; Answer: c) ;
  • 5. 23. What will happen when the structure is declared? a) it will not allocate any memory b) it will allocate the memory c) it will be declared and initialized d) none of the mentioned Answer: a) it will not allocate any memory 24. The declaration of the structure is also called as? a) structure creator b) structure signifier c) structure specifier d) none of the mentioned Answer: c) structure specifier 25. Which of the following is a properly defined structure? a) struct {int a;} b) struct a_struct {int a;} c) struct a_struct int a; d) struct a_struct {int a;}; Answer: d) struct a_struct {int a;}; 26. Which of the following accesses a variable in structure *b? a) b->var; b) b.var; c) b-var; d) b>var; Answer: a) b->var; 27. What is the output of this program? 1.#include <iostream> 2. #include <string.h> 3. using namespace std; 4. int main() 5. { 6. struct student 7. { 8. int num; 9. char name[25]; 10. }; 11. student stu; 12. stu.num = 123; 13. strcpy(stu.name, "John"); 14. cout << stu.num << endl; 15. cout << stu.name << endl; 16. return 0; 17. }
  • 6. a) 123-john b) john-john c) compile time error d) none of the mentioned Answer: a) 123-john 28. What is the output of this program? 1. #include <iostream> 2. using namespace std; 3. struct Time 4. { 5. int hours; 6. int minutes; 7. int seconds; 8. }; 9. int toSeconds(Time now); 10. int main() 11. { 12. Time t; 13. t.hours = 5; 14. t.minutes = 30; 15. t.seconds = 45; 16. cout << "Total seconds: " << toSeconds(t) << endl; 17. return 0; 18. } 19. int toSeconds(Time now) 20. { 21. return 3600 * now.hours + 60 * now.minutes + now.se conds; 22. } a) 19845 b) 20000 c) 15000 d) 19844 Answer: a) 19845
  • 7. 29. What will be the output of this program? 1. #include <iostream> 2. using namespace std; 3. int main() 4. { 5. struct ShoeType 6. { 7. string style; 8. double price; 9. }; 10. ShoeType shoe1, shoe2; 11. shoe1.style = "Adidas"; 12. shoe1.price = 9.99; 13. cout << shoe1.style << " $ "<< shoe1.price; 14. shoe2 = shoe1; 15. shoe2.price = shoe2.price / 9; 16. cout << shoe2.style << " $ "<< shoe2.price; 17. return 0; 18. } a) Adidas $ 9.99Adidas $ 1.11 b) Adidas $ 9.99Adidas $ 9.11 c) Adidas $ 9.99Adidas $ 11.11 d) none of the mentioned Answer: a) Adidas $ 9.99Adidas $ 1.11 30. What is the output of this program? 1.#include <iostream> 2. using namespace std; 3. struct sec 4. { 5. int a; 6. char b; 7. }; 8. int main() 9. { 10. struct sec s ={25,50}; 11. struct sec *ps =(struct sec *)&s; 12. cout << ps->a << ps->b; 13. return 0; 14. } a) 252 b) 253 c) 254 d) 262
  • 8. Answer: a) 252 31. Where does the execution of the program starts? a) user-defined function b) main function c) void function d) else function Answer: b) main function 32. What are mandatory parts in the function declaration? a) return type, function name b) return type, function name, parameters c) parameters, function name d) parameters, variables Answer: a) return type, function name 33. which of the following is used to terminate the function declaration? a) : b) ) c) ; d) ] Answer: c) ; 34. How many can max number of arguments present in function in the c99 compiler? a) 99 b) 90 c) 102 d) 127 Answer: d) 127 35. Which is more effective while calling the functions? a) call by value b) call by reference c) call by pointer d) call by object Answer: b) call by reference 36. What is the scope of the variable declared in the user defined function? a) whole program b) only inside the {} block c) the main function d) header section Answer: b) only inside the {} block 37. How many minimum number of functions should be present in a C++ program for its execution?
  • 9. a) 0 b) 1 c) 2 d) 3 Answer: b) 1 38. Which of the following is the default return value of functions in C++? a) int b) char c) float d) void Answer: a) int 39. What happens to a function defined inside a class without any complex operations (like looping, a large number of lines, etc)? a) It becomes a virtual function of the class b) It becomes a default calling function of the class c) It becomes an inline function of the class d) The program gives an error Answer: c) It becomes an inline function of the class 40. What is an inline function? a) A function that is expanded at each call during execution b) A function that is called during compile time c) A function that is not checked for syntax errors d) A function that is not checked for semantic analysis Answer: a) A function that is expanded at each call during execution 41. An inline function is expanded during ______________ a) compile-time b) run-time c) never expanded d) end of the program Answer: b) run-time 42. In which of the following cases inline functions may not word? i) If the function has static variables. ii) If the function has global and register variables. iii) If the function contains loops iv) If the function is recursive a) i, iv b) iii, iv c) ii, iii, iv d) i, iii, iv Answer: d) i, iii, iv
  • 10. 43. When we define the default values for a function? a) When a function is defined b) When a function is declared c) When the scope of the function is over d) When a function is called Answer: b) When a function is declared 44. Where should default parameters appear in a function prototype? a) To the rightmost side of the parameter list b) To the leftmost side of the parameter list c) Anywhere inside the parameter list d) Middle of the parameter list Answer: a) To the rightmost side of the parameter list 45. If an argument from the parameter list of a function is defined constant then _______________ a) It can be modified inside the function b) It cannot be modified inside the function c) Error occurs d) Segmentation fault Answer: b) It cannot be modified inside the function 46. Which of the following feature is used in function overloading and function with default argument? a) Encapsulation b) Polymorphism c) Abstraction d) Modularity Answer: c) Abstraction 47. From which function the execution of a C++ program starts? a) start() function b) main() function c) new() function d) end() function Answer: b) main() function 48. Which of the following is important in a function? a) Return type b) Function name c) Both return type and function name d) The return type, function name and parameter list Answer: c) Both return type and function name 49. What will be the output of the following C++ code?
  • 11. #include <iostream> using namespace std; int fun(int=0, int = 0); int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); } a) -5 b) 0 c) 10 d) 5 Answer: d) 5 50. What will be the output of the following C++ code? #include <iostream> using namespace std; void square (int *x, int *y) { *x = (*x) * --(*y); } int main ( ) { int number = 30; square(&number, &number); cout << number; return 0; } a) 870 b) 30 c) Error d) Segmentation fault Answer: a) 870 51. What does a class in C++ holds? a) data b) functions c) both data & functions d) none of the mentioned Answer: c) both data & functions 52. How many specifiers are present in access specifiers in class? a) 1
  • 12. b) 2 c) 3 d) 4 Answer: c) 3 53. Which is used to define the member of a class externally? a) : b) :: c) # d) none of the mentioned Answer: b) :: 54. Which other keywords are also used to declare the class other than class? a) struct b) union c) object d) both struct & union Answer: d) both struct & union 55. Which of the following is a valid class declaration? a) class A { int x; }; b) class B { } c) public class A { } d) object A { int x; }; Answer: a) class A { int x; }; 56. The data members and functions of a class in C++ are by default ____________ a) protected b) private c) public d) none of the mentioned Answer: b) private
  • 13. 57. Constructors are used to a) initialize the objects b) construct the data members c) both initialize the objects & construct the data members d) none of the mentioned Answer: a) initialize the objects 58. When struct is used instead of the keyword class means, what will happen in the program? a) access is public by default b) access is private by default c) access is protected by default d) none of the mentioned Answer: a) access is public by default 59. Which category of data type a class belongs to? a) Fundamental data type b) Derived data type c) User defined derived data type d) Atomic data type Answer: c) User defined derived data type 60. Which operator a pointer object of a class uses to access its data members and member functions? a) . b) -> c) : d) :: Answer: b) -> 61. How the objects are self-referenced in a member function of that class. a) Using a special keyword object b) Using this pointer c) Using * with the name of that object d) By passing self as a parameter in the member function Answer: b) Using this pointer 62. What does a mutable member of a class mean? a) A member that can never be changed b) A member that can be updated only if it not a member of constant object
  • 14. c) A member that can be updated even if it a member of constant object d) A member that is global throughout the class Answer: c) A member that can be updated even if it a member of constant object 63. Pick the incorrect statement about inline functions in C++? a) They reduce function call overheads b) These functions are inserted/substituted at the point of call c) Saves overhead of a return call from a function d) They are generally very large and complicated function Answer: d) They are generally very large and complicated function. 64. Inline functions are avoided when ____________________________ a) function contains static variables b) function have recursive calls c) function have loops d) all of the mentioned Answer: d) all of the mentioned 65. Which functions of a class are called inline functions? a) All the functions containing declared inside the class b) All functions defined inside or with the inline keyword c) All the functions accessing static members of the class d) All the functions that are defined outside the class Answer: b) All functions defined inside or with the inline keyword 66. Where does the object is created? a) class b) constructor c) destructor d) attributes Answer: a) class 67. How to access the object in the class? a) scope resolution operator b) ternary operator
  • 15. c) direct member access operator d) none of the mentioned Answer: c) direct member access operator 68. Which of these following members are not accessed by using direct member access operator? a) public b) private c) protected d) both private & protected Answer: d) both private & protected 69. Pick out the other definition of objects. a) member of the class b) associate of the class c) attribute of the class d) instance of the class Answer: d) instance of the class 70. How many objects can present in a single class? a) 1 b) 2 c) 3 d) as many as possible Answer: d) as many as possible 71. Where is the derived class is derived from? a) derived b) base c) both derived & base d) None of the mentioned Answer: b) base 72. Pick out the correct statement. a) A derived class’s constructor cannot explicitly invokes its base class’s constructor b) A derived class’s destructor cannot invoke its base class’s destructor
  • 16. c) A derived class’s destructor can invoke its base class’s destructor d) None of the mentioned Answer: b) A derived class’s destructor cannot invoke its base class’s destructor 73. Which of the following can derived class inherit? a) members b) functions c) both members & functions d) none of the mentioned Answer: c) both members & functions 74. Which class is used to design the base class? a) abstract class b) derived class c) base class d) none of the mentioned Answer: a) abstract class 75. Which is used to create a pure virtual function? a) $ b) =0 c) & d) ! Answer: b) =0 76. Which is also called as abstract class? a) virtual function b) pure virtual function c) derived class d) none of the mentioned Answer: b) pure virtual function
  • 17. 77. Where does the abstract class is used? a) base class only b) derived class c) both derived & base class d) none of the mentioned Answer: a) base class only 78. Which special character is used to mark the end of class? a) ; b) : c) # d) $ Answer: a) ; 79. Which among the following is called first, automatically, whenever an object is created? a) Class b) Constructor c) New d) Trigger Answer: b) Constructor 80. Which among the following is not a necessary condition for constructors? a) Its name must be same as that of class b) It must not have any return type c) It must contain a definition body d) It can contains arguments Answer: c) It must contain a definition body 81. Which among the following is correct? a) class student{ public: int student(){} }; b) class student{ public: void student (){} }; c) class student{ public: student{}{} }; d) class student{ public: student(){} }; Answer: d) class student{ public: student(){} }; 82. In which access should a constructor be defined, so that object of the class can be created in any function? a) Public b) Protected c) Private d) Any access specifier will work
  • 18. Answer: a) Public 83. How many types of constructors are available for use in general (with respect to parameters)? a) 2 b) 3 c) 4 d) 5 Answer: a) 2 84. How many types of constructors are available, in general, in any language? a) 2 b) 3 c) 4 d) 5 Answer: b) 3 85. Choose the correct option for the following code. 86. class student 87. { 88. int marks; 89. } 90. student s1; 91. student s2=2; a) Object s1 should be passed with argument. b) Object s2 should not be declared c) Object s2 will not be created, but program runs d) Program gives compile time error Answer: d) Program gives compile time error 92. Which constructor is called while assigning some object with another? a) Default b) Parameterized c) Copy d) Direct assignment is used Answer: c) Copy 93. Which specifier applies only to the constructors? a) Public b) Protected c) Implicit d) Explicit Answer: d) Explicit 94. Which among the following is true? a) Default constructor can’t be defined by the programmer b) Default parameters constructor isn’t equivalent to default constructor
  • 19. c) Default constructor can be called explicitly d) Default constructor is and always called implicitly only Answer: c) Default constructor can be called explicitly 95. Which type of constructor can’t have a return type? a) Default b) Parameterized c) Copy d) Constructors don’t have a return type Answer: d) Constructors don’t have a return type 96. Copy constructor is a constructor which ________________ a) Creates an object by copying values from any other object of same class b) Creates an object by copying values from first object created for that class c) Creates an object by copying values from another object of another class d) Creates an object by initializing it with another previously created object of same class Answer: d) Creates an object by initializing it with another previously created object of same class 97. The copy constructor can be used to: a) Initialize one object from another object of same type b) Initialize one object from another object of different type c) Initialize more than one object from another object of same type at a time d) Initialize all the objects of a class to another object of another class Answer: a) Initialize one object from another object of same type 98. The copy constructors can be used to ________ a) Copy an object so that it can be passed to a class b) Copy an object so that it can be passed to a function c) Copy an object so that it can be passed to another primitive type variable d) Copy an object for type casting Answer: b) Copy an object so that it can be passed to a function 99. Which returning an object, we can use ____________ a) Default constructor b) Zero argument constructor c) Parameterized constructor d) Copy constructor Answer: d) Copy constructor 100. If a class implements some dynamic memory allocations and pointers then _____________ a) Copy constructor must be defined b) Copy constructor must not be defined c) Copy constructor can’t be defined d) Copy constructor will not be used
  • 20. Answer: a) Copy constructor must be defined 101. What is the syntax of copy constructor? a) classname (classname &obj){ /*constructor definition*/ } b) classname (cont classname obj){ /*constructor definition*/ } c) classname (cont classname &obj){ /*constructor definition*/ } d) classname (cont &obj){ /*constructor definition*/ } Answer: c) classname (cont classname &obj){ /*constructor definition*/ } 102. Which among the following best describes constructor overloading? a) Defining one constructor in each class of a program b) Defining more than one constructor in single class c) Defining more than one constructor in single class with different signature d) Defining destructor with each constructor Answer: c) Defining more than one constructor in single class with different signature 103. Can constructors be overloaded in derived class? a) Yes, always b) Yes, if derived class has no constructor c) No, programmer can’t do it d) No, never Answer: d) No, never 104. Does constructor overloading include different return types for constructors to be overloaded? a) Yes, if return types are different, signature becomes different b) Yes, because return types can differentiate two functions c) No, return type can’t differentiate two functions d) No, constructors doesn’t have any return type Answer: d) No, constructors doesn’t have any return type 105. When is the constructor called for an object? a) As soon as overloading is required b) As soon as class is derived c) As soon as class is created d) As soon as object is created Answer: d) As soon as object is created 106. Which among the following best describes destructor? a) A function which is called just before the objects are destroyed b) A function which is called after each reference to the object c) A function which is called after termination of the program d) A function which is called before calling any member function Answer: a) A function which is called just before the objects are destroyed
  • 21. 107. Which among the following represents correct constructor? a) ()classname b) ~classname() c) –classname() d) classname() Answer: d) classname() 108. Which among the following is correct syntax for the destructors? a) classname() b) ()classname c) ~classname() d) -classname() Answer: c) ~classname() 109. Which among the following is correct for abstract class destructors? a) It doesn’t have destructors b) It has destructors c) It may or may not have destructors d) It contains an implicit destructor Answer: a) It doesn’t have destructors 110. When is the destructor of a global object called? a) Just before end of program b) Just after end of program c) With the end of program d) Anytime when object is not needed Answer: a) Just before end of program 111. Destructors doesn’t accept parameters. a) True b) False Answer: a) True 112. Destructors can be ________ a) Abstract type b) Virtual c) Void d) Any type depending on situation Answer: b) Virtual 113. Global destructors execute in ___________ order after main function is terminated a) Sequential b) Random
  • 22. c) Reverse d) Depending on priority Answer: c) Reverse 114. Which among the following best describes the Inheritance? a) Copying the code already written b) Using the code already written once c) Using already defined functions in programming language d) Using the data and functions into derived segment Answer: d) Using the data and functions into derived segment 115. How many basic types of inheritance are provided as OOP feature? a) 4 b) 3 c) 2 d) 1 Answer: a) 4 116. Which among the following best defines single level inheritance? a) A class inheriting a derived class b) A class inheriting a base class c) A class inheriting a nested class d) A class which gets inherited by 2 classes Answer: b) A class inheriting a base class 117. Which programming language doesn’t support multiple inheritance? a) C++ and Java b) C and C++ c) Java and SmallTalk d) Java Answer: d) Java 118. Which is the correct syntax of inheritance? a) class derived_classname : base_classname{ /*define class body*/ }; b) class base_classname : derived_classname{ /*define class body*/ }; c) class derived_classname : access base_classname{ /*define class body*/ }; d) class base_classname :access derived_classname{ /*define class body*/ }; Answer: c) class derived_classname : access base_classname{ /*define class body*/ };
  • 23. 119. Which type of inheritance leads to diamond problem? a) Single level b) Multi-level c) Multiple d) Hierarchical Answer: c) Multiple 120. Members which are not intended to be inherited are declared as: a) Public members b) Protected members c) Private members d) Private or Protected members Answer: c) Private members 121. The private members of the base class are visible in derived class but are not accessible directly. a) True b) False Answer: a) True 122. How can you make the private members inheritable? a) By making their visibility mode as public only b) By making their visibility mode as protected only c) By making their visibility mode as private in derived class d) It can be done both by making the visibility mode public or protected Answer: d) It can be done both by making the visibility mode public or protected 123. While inheriting a class, if no access mode is specified, then which among the following is true? (in C++) a) It gets inherited publicly by default b) It gets inherited protected by default c) It gets inherited privately by default d) It is not possible Answer: c) It gets inherited privately by default 124. How many types of inheritance are possible in C++? a) 2 b) 3 c) 4 d) 5 Answer: d) 5
  • 24. 125. Which among the following best describes multiple inheritance? a) Two classes being parent of any other classes b) Three classes being parent of other classes c) More than one class being parent of other child classes d) More than one class being parent of single child Answer: d) More than one class being parent of single child 126. How many types of inheritance can be used at a time in single program? a) Any two types b) Any three types c) Any 4 types d) Any type, any number of times Answer: d) Any type, any number of times 127. Which type of inheritance results in diamond problem? a) Single level b) Hybrid c) Hierarchical d) Multilevel Answer: b) Hybrid 128. Which type of inheritance cannot involve private inheritance? a) Single level b) Multiple c) Hybrid d) All types can have private inheritance Answer: d) All types can have private inheritance 129. Which among the following defines single level inheritance? a) One base class derives another class b) One derived class inherits from one base class c) One base class inherits from one derived class d) One derived class derives from another derived class Answer: b) One derived class inherits from one base class
  • 25. 130. If class A and class B are derived from class C and class D, then ________________ a) Those are 2 pairs of single inheritance b) That is multilevel inheritance c) Those is enclosing class d) Those are all independent classes Answer: d ) Those are 2 pairs of single inheritance 131. If single inheritance is used, program will contain ________________ a) At least 2 classes b) At most 2 classes c) Exactly 2 classes d) At most 4 classes Answer: a) At least 2 classes 132. Single level inheritance supports _____________ inheritance. a) Runtime b) Compile time c) Multiple inheritance d) Language independency Answer: a) Runtime 133. Which among the following is false for single level inheritance? a) There can be more than 2 classes in program to implement single inheritance b) There can be exactly 2 classes to implement single inheritance in a program c) There can be more than 2 independent classes involved in single inheritance d) The derived class must implement all the abstract method if single inheritance is used Answer: c) There can be more than 2 independent classes involved in single inheritance 134. Single level inheritance will be best for___________ a) Inheriting a class which performs all the calculations b) Inheriting a class which can print all the calculation results c) Inheriting a class which can perform and print all calculations d) Inheriting all the classes for different calculations Answer: b) Inheriting a class which can print all the calculation results
  • 26. 135. Which among the following best defines multilevel inheritance? a) A class derived from another derived class b) Classes being derived from other derived classes c) Continuing single level inheritance d) Class which have more than one parent Answer: b) Classes being derived from other derived classes 136. Multilevel inheritance allows _________________ in the program. a) Only 7 levels of inheritance b) At least 7 levels of inheritance c) At most 16 levels of inheritance d) As many levels of inheritance as required Answer: d) As many levels of inheritance as required 137. What is minimum number of levels for a implementing multilevel inheritance? a) 1 b) 2 c) 3 d) 4 Answer: c) 3 138. In multilevel inheritance one class inherits _______________ a) Only one class b) More than one class c) At least one class d) As many classes as required Answer: a) Only one class 139. All the classes must have all the members declared private to implement multilevel inheritance. a) True b) False Answer: b) False 140. Multiple inheritance is ____________________ a) When a class is derived from another class b) When a class is derived from two or more classes c) When a class is derived from other two derived classes d) When a class is derived from exactly one class Answer: b) When a class is derived from two or more classes
  • 27. 141. Which problem arises due to multiple inheritance, if hierarchical inheritance is used previously for its base classes? a) Diamond b) Circle c) Triangle d) Loop Answer: a) Diamond 142. How many classes should a program contain to implement the multiple inheritance? a) Only 1 b) At least 1 c) At least 3 d) Exactly 3 Answer: c) At least 3 143. Why does diamond problem arise due to multiple inheritance? a) Methods with same name creates ambiguity and conflict b) Methods inherited from the superclass may conflict c) Derived class gets overloaded with more than two class methods d) Derived class can’t distinguish the owner class of any derived method Answer: a) Methods with same name creates ambiguity and conflict 144. How many base classes can a derived class have which is implementing multiple inheritance? a) Only 2 b) At least 2 c) At most 2 d) As many as required Answer: d 145. Which among the following is best to define hierarchical inheritance? a) More than one classes being derived from one class b) More than 2 classes being derived from single base class c) At most 2 classes being derived from single base class d) At most 1 class derived from another class Answer: a) More than one classes being derived from one class
  • 28. 146. How many classes must be there to implement hierarchical inheritance ? a) Exactly 3 b) At least 3 c) At most 3 d) At least 1 Answer: b) At least 3 147. How many classes can be derived from the base class using hierarchical inheritance? a) As many as required b) Only 7 c) Only 3 d) Up to 127 Answer: a) As many as required 148. How many types of inheritance should be used for hybrid ? a) Only 1 b) At least 2 c) At most two d) Always more than 2 Answer: b) At least 2 149. Which type of inheritance must be used so that the resultant is hybrid? a) Multiple b) Hierarchical c) Multilevel d) None Answer: d) None 150. What is the maximum number of classes allowed in hybrid inheritance? a) 7 b) 127 c) 255 d) As many as required Answer: d) As many as required 151. Which among the following best describes polymorphism? a) It is the ability for a message/data to be processed in more than one form b) It is the ability for a message/data to be processed in only 1 form
  • 29. c) It is the ability for many messages/data to be processed in one way d) It is the ability for undefined message/data to be processed in at least one way Answer: a) It is the ability for a message/data to be processed in more than one form 152. What do you call the languages that support classes but not polymorphism? a) Class based language b) Procedure Oriented language c) Object-based language d) If classes are supported, polymorphism will always be supported Answer: c) Object-based language 153. Which among the following is the language which supports classes but not polymorphism? a) SmallTalk b) Java c) C++ d) Ada Answer: d) Ada 154. If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called? a) Inheritance b) Overloading c) Polymorphism d) Overriding Answer: c) Polymorphism 155. Which class/set of classes can illustrate polymorphism in the following code: abstract class student { public : int marks; calc_grade(); } class topper:public student { public : calc_grade() { return 10; } }; class average:public student { public : calc_grade() { return 20; }
  • 30. }; class failed{ int marks; }; a) Only class student can show polymorphism b) Only class student and topper together can show polymorphism c) All class student, topper and average together can show polymorphism d) Class failed should also inherit class student for this code to work for polymorphism Answer: c) All class student, topper and average together can show polymorphism 156. Which type of function among the following shows polymorphism? a) Inline function b) Virtual function c) Undefined functions d) Class member functions Answer: b) Virtual function 157. In case of using abstract class or function overloading, which function is supposed to be called first? a) Local function b) Function with highest priority in compiler c) Global function d) Function with lowest priority because it might have been halted since long time, because of low priority Answer: b) Function with highest priority in compiler 158. Which among the following can’t be used for polymorphism? a) Static member functions b) Member functions overloading c) Predefined operator overloading d) Constructor overloading Answer: a) Static member functions 159. What is output of the following program? class student { public : int marks; void disp() { cout<<”its base class” }; class topper:public student { public : void disp() { cout<<”Its derived class”; } }
  • 31. void main() { student s; topper t; s.disp(); t.disp(); } a)Its base classIts derived class b) Its base class Its derived class c) Its derived classIts base class d) Its derived class Its base class Answer: a) Its base classIts derived class 160. Which among the following can show polymorphism? a) Overloading || b) Overloading += c) Overloading << d) Overloading && Answer: c) Overloading << 161. Find the output of the program: class education { char name[10]; public : disp() { cout<<”Its education system”; } class school:public education { public: void dsip() { cout<<”Its school education system”; } }; void main() { school s; s.disp(); } } a) Its school education system b) Its education system c) Its school education systemIts education system d) Its education systemIts school education system Answer: a) Its school education system 162. Polymorphism is possible in C language. a) True b) False Answer: a) True
  • 32. 163. Which problem may arise if we use abstract class functions for polymorphism? a) All classes are converted as abstract class b) Derived class must be of abstract type c) All the derived classes must implement the undefined functions d) Derived classes can’t redefine the function Answer: c) All the derived classes must implement the undefined functions 164. Which among the following is not true for polymorphism? a) It is feature of OOP b) Ease in readability of program c) Helps in redefining the same functionality d) Increases overhead of function definition always Answer: d) Increases overhead of function definition always 165. If 2 classes derive one base class and redefine a function of base class, also overload some operators inside class body. Among these two things of function and operator overloading, where is polymorphism used? a) Function overloading only b) Operator overloading only c) Both of these are using polymorphism d) Either function overloading or operator overloading because polymorphism can be applied only once in a program Answer: d) Either function overloading or operator overloading because polymorphism can be applied only once in a program 166. Which header file is required to use file I/O operations? a) <ifstream> b) <ostream> c) <fstream> d) <iostream> Answer: c) <fstream> 167. Which of the following is used to create an output stream? a) ofstream b) ifstream c) iostream d) fsstream Answer: a) ofstream 168. Which of the following is used to create a stream that performs both input and output operations? a) ofstream b) ifstream
  • 33. c) iostream d) fstream Answer: d) fstream 169. Which of the following is not used as a file opening mode? a) ios::trunc b) ios::binary c) ios::in d) ios::ate Answer: a) ios::trunc 170. Which of the following statements are correct? 1) It is not possible to combine two or more file opening mode in open() method. 2) It is possible to combine two or more file opening mode in open() method. 3) ios::in and ios::out are input and output file opening mode respectively. a) 1, 3 b) 2, 3 c) 3 only d) 1, 2 Answer: a) 1, 3 171. By default, all the files in C++ are opened in _________ mode. a) Text b) Binary c) ISCII d) VTC Answer: a) Text 172. What is the use of ios::trunc mode? a) To open a file in input mode b) To open a file in output mode c) To truncate an existing file to half d) To truncate an existing file to zero Answer: d) To truncate an existing file to zero 173. Which of the following is the default mode of the opening using the ofstream class? a) ios::in b) ios::out c) ios::app d) ios::trunk Answer: b) ios::out
  • 34. 174. What is the return type open() method? a) int b) char c) bool d) float Answer: c) bool 175. Which of the following is not used to seek file pointer? a) ios::set b) ios::end c) ios::cur d) ios::beg Answer: a) ios::set 176. Which of the following is the default mode of the opening using the ifstream class? a) ios::in b) ios::out c) ios::app d) ios::trunk Answer: a) ios::in 177. Which of the following is the default mode of the opening using the fstream class? a) ios::in b) ios::out c) ios::in|ios::out d) ios::trunk Answer: c) ios::in|ios::out 178. Which function is used in C++ to get the current position of file pointer in a file? a) tell_p() b) get_pos() c) get_p() d) tell_pos() Answer: a) tell_p() 179. Which function is used to reposition the file pointer? a) moveg() b) seekg() c) changep() d) go_p() Answer: b) seekg()
  • 35. 180. Which of the following is used to move the file pointer to start of a file? a) ios::beg b) ios::start c) ios::cur d) ios::first Answer: a) ios::beg 181. What is the use of IO class? a) To handle all the input operations b) To handle all the output operations c) To handle all the input and output operations d) To handle all the input and output to the standard input Answer: c) To handle all the input and output operations 182. IO class provides input and output through ______________________ a) Data streams b) Serialization c) File system d) Data streams, serialization and file system Answer: d) Data streams, serialization and file system 183. Which among the following class contains the methods to access character based console device? a) Console b) File c) Device d) Pipe Answer: a) Console 184. File class is ____________________________ a) An abstract of file representation only b) An abstract of path names only c) An abstract which can be used to represent path names or file d) An abstract which can represent a file in any format Answer: c) An abstract which can be used to represent path names or file 185. What is a File Descriptor? a) A handle for machine specific structure of an open file b) A handle for program specific structure of an open file c) A handle for compiler specific structure of an open file d) A handle for representing device files structure Answer: a) A handle for machine specific structure of an open file 186. File Input Stream _________________________ a) Gets the input stream from any device file
  • 36. b) Gets the input stream from any open socket c) Gets the input stream from any cache d) Gets the input stream from any open file only Answer: d) Gets the input stream from any open file only 187. What does File Permission class do? a) This class is used to give permission rights to a file b) This class is used to restrict use of permissions c) This class is used to represent device access permissions d) This class is used to represent file access permissions Answer: d) This class is used to represent file access permissions 188. Which class among the following makes incorrect assumptions? a) Line Number Input Stream b) Line Number Reader c) Line Reader d) Line Buffer Answer: a) Line Number Input Stream 189. Reader class is _________________ a) Used to read from files b) Abstract class to read character streams c) Abstract class to input character streams d) Used to take input from standard input stream Answer: b) Abstract class to read character streams 190. Which class can handle IO class interrupt? a) ExceptionIO b) InteruptedIO c) InteruptedIOException d) IOInteruptException Answer: c) InteruptedIOException 191. String Reader handles _____________________ a) Any character stream b) A character stream whose source is an array c) A character stream whose source is character array d) A character stream whose source is String only Answer: d) A character stream whose source is String only 192. Which exception handler can be used when character encoding is not supported? a) UnsupportedException b) UnsupportedEncodingException
  • 37. c) SupportException d) EncodingException Answer: b) UnsupportedEncodingException 193. PushBackReader allows the streams to be pushed back to the stream. a) True b) False Answer: a) True 194. RandomAccessFile can be used to _______________________ a) Read from a random access file b) Write to a random access file c) Read and write to a random access file d) Restricts read and write to a random access file Answer: c) Read and write to a random access file 195. Which among the following is a serialization descriptor for any class? a) StreamClass b) ObjectStreamClass c) ObjectStream d) StreamObjectClass Answer: b) ObjectStreamClass
  • 38. 196. What is the output of the following program? 1. #include <iostream> 2. using namespace std; 3. class Box 4. { 5. public : 6. double length; 7. double breadth; 8. double height; 9. }; 10. int main( ) 11. { 12. Box Box1; 13. double volume; 14. Box1.height = 5; 15. Box1.length = 6; 16. Box1.breadth = 7.1; 17. volume = Box1.height * Box1.length * Box1.breadth; 18. cout << "Volume of Box1 : " << volume <<endl; 19. return 0; 20. } a)210 b)213 c)215 d) 217 Answer: b)213
  • 39. 197. What is the output of this program? 1. #include <iostream> 2. using namespace std; 3. class rect 4. { 5. int x, y; 6. public: 7. void val (int, int); 8. int area () 9. { 10. return (x * y); 11. } 12. }; 13. void rect::val (int a, int b) 14. { 15. x = a; 16. y = b; 17. } 18. int main () 19. { 20. rect rect; 21. rect.val (3, 4); 22. cout << "rect area: " << rect.area(); 23. return 0; 24. } a) rect area: 24 b) rect area: 12 c) compile error because rect is as used as class name and variable name in line #20 d) none of the mentioned Answer: b) rect area: 12
  • 40. 198. What is the correct syntax of accessing a static member of a Class? --------------------------- Example class: class A { public: static int value; } --------------------------- a) A.value b) A::value c) A->value d) A^value Answer: b) A::value 199. What will be the output of the following C++ code? #include <iostream> using namespace std; class S { int m; public: #define MAC(S::m) }; int main(int argc, char const *argv[]) { cout<<"Hello World"; return 0; } a) Hello World b) Error c) Segmentation Fault d) Blank Space Answer: b) Error
  • 41. 200. What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { static int a; public: void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; int main(int argc, char const *argv[]) { A a1 = A(); a1.change(5); a1.value_of_a(); return 0; } a) 5 b) Garbage value c) Error d) Segmentation fault Answer: c) Error