1. Every class has at least one constructor function, even when none is declared.
Correct : A. true
2. Can constructors be overloaded?
Correct : A. true
3. What is the difference between struct and class in terms of Access Modifier?
Correct : C. by default all the struct members are public while by default class members are private.
4. An abstract class can be instantiated.
Correct : B. false
5. The default access level assigned to members of a class is
Correct : A. private
6. There is nothing like a virtual constructor of a class.
Correct : B. false
7. Which of the following operators allow defining the member functions of a class outside the class?
Correct : A. ::
8. Which type of class has only one unique value for all the objects of that same class?
Correct : C. static
9. Which one of the following is not a fundamental data type in C++?
Correct : B. string
10. What is a constructor?
Correct : C. a function automatically called whenever a new object of this class is created.
11. Under what conditions a destructor destroys an object?
Correct : D. both a and b.
12. When class B is inherited from class A, what is the order in which the constructers of those classes are called
Correct : A. class a first class b next
13. Which one of the following is not a valid reserved keyword in C++?
Correct : C. implicit
14. Variables declared in the body of a particular member function are known as data members and can be used in all member functions of the class.
Correct : B. false
15. In a class definition, data or functions designated private are accessible
Correct : C. to member functions of that class.
16. A member function can always access the data
Correct : A. in the object of which it is a member.
17. Classes are useful because they
Correct : D. options a, b and c
18. For the object for which it was called, a const member function
Correct : D. can modify neither const nor non-const member data.
19. Dividing a program into functions
Correct : D. option b and c
20. An expression
Correct : D. option a and b
21. A variable of type char can hold the value 301.
Correct : B. false
22. In an assignment statement, the value on the left of the equal sign is always equal to the value on the right.
Correct : B. false
23. It’s perfectly all right to use variables of different data types in the same arithmetic expression.
Correct : A. true
24. A function’s single most important role is to
Correct : D. help organize a program into conceptual units.
25. A function argument is
Correct : C. a value sent to the function by the calling program.
26. When arguments are passed by value, the function works with the original arguments in the calling program.
Correct : B. false
27. Which of the following can legitimately be passed to a function?
Correct : D. all of the above
28. How many values can be returned from a function?
Correct : B. 1
29. When a function returns a value, the entire function call can appear on the right side of the equal sign and be assigned to another variable.
Correct : A. true
30. When an argument is passed by reference
Correct : D. the function accesses the argument’s original value in the calling program.
31. Overloaded functions
Correct : D. a and c
32. A static local variable is used to
Correct : D. b and c
33. In C++ there can be an array of four dimensions.
Correct : A. true
34. When an array name is passed to a function, the function
Correct : D. a and b
35. The compiler will complain if you try to access array element 14 in a 10-element array.
Correct : B. false
36. The extraction operator (>>) stops reading a string when it encounters a space.
Correct : A. true
37. You can read input that consists of multiple lines of text using
Correct : D. the cin.get() function with three arguments.
38. You should prefer C-strings to the Standard C++ string class in new programs.
Correct : B. false
39. Objects of the string class
Correct : D. both b and c
40. Can destuctors be private in C++?
Correct : A. yes
41. What is value of size?
Correct : C. 20
42. What value will be printed for data.i?
Correct : D. unpredictable value
43. What is the compilation error for this
program?
Correct : B. cout and cin not declared in scope
44. What will be the output of the program?
Correct : C. will not compile
45. What is the output of the program?
Correct : D. compilation error
46. Which function will change the state of the object?
Correct : A. only set()
47. What will be the output of the following program?
Correct : C. compilation error: variable x is private in test
48. The only integer that can be assigned directly to a pointer is
Correct : A. 0
49. Which of the following feature is not supported by C++?
Correct : B. reflection
50. The operators that cannot be overloaded is
Correct : C. ::
51. Empty parentheses following a function name in a function prototype indicate that the function does not require any parameters to perform its task.
Correct : A. true
52. C++ programmers concentrate on creating , which contain data members and the member functions that manipulate those data members and provide services to clients.
Correct : B. classes
53. Which of the following is FALSE about references in C++
Correct : D. references cannot refer to constant value
54. What will be the output of following program?
#include <iostream> using namespace std;
class Test{
public:
Test() { cout <<"Hello from Test() "; }
} a;
int main()
{
cout <<"Main Started "; return 0;
}
Correct : C. hello from test() main started
55. Which of the following is true about constructors.
They cannot be virtual.
They cannot be private.
They are automatically called by new operator
Correct : B. only 1 and 3
56. Which of the following operators are overloaded by default by the compiler?
1) Comparison Operator ( == )
2) Assignment Operator ( = )
Correct : C. only 2
57. Which of the following is true about inline functions and macros.
Correct : D. all of the above
58. In C++, const qualifier can be applied to
Member functions of a class
Function arguments
To a class data member which is declared as static
Reference variables
Correct : C. all
59. Which type is best suited to represent the logical values?
Correct : B. boolean
60. The following is the C++ style comment
Correct : A. //
61. Which of the following statements is false?
Correct : D. main() terminates with semicolon.
62. Functions can returns
Correct : D. all of above
63. Which of the following control expressions are valid for an if statement?
Correct : C. either a or b
64. What will be the values of x, m and n after execution of the following statements? Int x, m, n;
m=10; n=15;
x= ++m + n++;
Correct : C. x=26, m=11, n=16
65. Which of the following approach is adapted by C++?
Correct : B. bottom-up
66. Which of the following is the correct class of the object cout?
Correct : C. ostream
67. Which of the following functions are performed by a constructor?
Correct : D. initialize objects
68. Which of the following ways are legal to access a class data member using this pointer?
Correct : A. this->x
69. Which operator is having right to left associativity in the following?
Correct : D. type cast
70. Which operator is having the highest precedence?
Correct : A. postfix
71. #include <iostream>
using namespace std;
int main()
{
int a;
a = 5 + 3 * 5;
cout <<a; return 0;
}
Correct : B. 20
72. In procedural programming the focus in on …...........
Correct : C. function
73. In object oriented programming the focus is on ….......
Correct : A. data
74. Which of the following feature of procedure oriented program is false?
Correct : A. makes use of bottom up approach
75. Which of the following feature of object oriented program is false?
Correct : D. the focus is on procedures
76. C++ was originally developed by ….......
Correct : B. bjarne sroustrups
77. Which of the following approach is adopted in C++?
Correct : B. bottom up
78. Which feature of C++ contain the concept of super class and subclass?
Correct : D. inheritance
79. The main intention of using inheritance is ….........
Correct : C. to extend the capabilities of base class
80. If particular software can be used in some other application than the one for which it is created then it reveals ….........
Correct : B. data reusability
81. Which of the following data type does not return anything?
Correct : D. void
82. How many objects can be created from an abstract class?
Correct : A. zero
83. Which of the following statements is correct for a static member function?
1. It can access only other static members of its class.
It can be called using the class name, instead of objects
Correct : C. both 1 and 2 are correct
84. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
Correct : A. compile-time error
85. Which of the following interface determines how your program will be used by other program?
Correct : A. public
86. What is the difference between struct and class in C++?
Correct : B. members of a class are private by default and members of struct are public by default. when deriving a struct from a class/struct, default access-specifier for a base class/struct is public and when deriving a class, default access specifier is private.
87. Predict the output of following C++ program
#include<iostream> using namespace std;
class Empty {}; int main()
{
cout <<sizeof(Empty); return 0;
}
Correct : A. a non zero value
88. class Test { int x;
};
int main()
{
Test t; cout <<t.x; return 0;
}
Correct : C. compile time error
89. Which of the following is true?
Correct : B. objects of a class do not share non-static members. every object has its own copy
90. Which of the following is true about the following program
#include <iostream> class Test
{
public:
int i;
void get();
};
void Test::get()
{
std::cout <<"Enter the value of i: "; std::cin >>i;
}
Test t; // Global object int main()
{
Test t; // local object t.get();
std::cout <<"value of i in local t: "<<t.i<<'\n';
::t.get();
std::cout <<"value of i in global t: "<<::t.i<<'\n'; return 0;
}
Correct : C. compiles and runs fine
91. Which of the following is true about new when compared with malloc. 1) new is an operator, malloc is a function 2) new calls constructor, malloc doesn't 3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type.
Correct : C. 1 and 2
92. Predict the output?
#include <iostream> using namespace std;
class Test
{
int x;
Test() { x = 5;}
};
int main()
{
Test *t = new Test; cout <<t->x;
}
Correct : A. compile time error
93. What happens when delete is used for a NULL pointer? int *ptr = NULL;
delete ptr;
Correct : C. no effect
94. Is it fine to call delete twice for a pointer?
#include<iostream> using namespace std;
int main()
{
int *ptr = new int; delete ptr;
delete ptr; return 0;
}
Correct : B. no
95. Which of the followings is/are automatically added to every class, if we do not write our own.
Correct : D. all
96. When a copy constructor may be called?
Correct : D. all
97. Output of following program?
#include<iostream> using namespace std; class Point {
Point() { cout <<"Constructor called"; }
};
int main()
{
Point t1; return 0;
}
Correct : A. compile time error
98. #include<iostream> using namespace std; class Point {
public:
Point() { cout <<"Constructor called"; }
};
int main()
{
Point t1, *t2; return 0;
}
Correct : C. constructor called
99. #include<iostream> using namespace std;
class X
{
public:
int x;
};
int main()
{
X a = {10};
X b = a;
cout <<a.x <<" " <<b.x; return 0;
}