McqMate
1. |
Every class has at least one constructor function, even when none is declared. |
A. | true |
B. | false |
Answer» A. true |
2. |
Can constructors be overloaded? |
A. | true |
B. | false |
Answer» A. true |
3. |
What is the difference between struct and class in terms of Access Modifier? |
A. | by default all the struct members are private while by default class members are public. |
B. | by default all the struct members are protected while by default class members are private. |
C. | by default all the struct members are public while by default class members are private. |
D. | by default all the struct members are public while by default class members are protected. |
Answer» C. by default all the struct members are public while by default class members are private. |
4. |
An abstract class can be instantiated. |
A. | true |
B. | false |
Answer» B. false |
5. |
The default access level assigned to members of a class is |
A. | private |
B. | public |
C. | protected |
D. | needs to be assigned |
Answer» A. private |
6. |
There is nothing like a virtual constructor of a class. |
A. | true |
B. | false |
Answer» B. false |
7. |
Which of the following operators allow defining the member functions of a class outside the class? |
A. | :: |
B. | ? |
C. | :? |
D. | % |
Answer» A. :: |
8. |
Which type of class has only one unique value for all the objects of that same class? |
A. | this |
B. | friend |
C. | static |
D. | both a and b |
Answer» C. static |
9. |
Which one of the following is not a fundamental data type in C++? |
A. | float |
B. | string |
C. | int |
D. | char |
Answer» B. string |
10. |
What is a constructor? |
A. | a class automatically called whenever a new object of this class is created. |
B. | a class automatically called whenever a new object of this class is destroyed. |
C. | a function automatically called whenever a new object of this class is created. |
D. | a function automatically called whenever a new object of this class is destroyed. |
Answer» C. a function automatically called whenever a new object of this class is created. |
11. |
Under what conditions a destructor destroys an object? |
A. | scope of existence has finished |
B. | object dynamically assigned and it is released using the operator delete. |
C. | program terminated. |
D. | both a and b. |
Answer» 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 |
A. | class a first class b next |
B. | class b first class a next |
C. | class b's only as it is the child class |
D. | class a's only as it is the parent class |
Answer» A. class a first class b next |
13. |
Which one of the following is not a valid reserved keyword in C++? |
A. | explicit |
B. | public |
C. | implicit |
D. | private |
Answer» 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. |
A. | true |
B. | false |
Answer» B. false |
15. |
In a class definition, data or functions designated private are accessible |
A. | to any function in the program. |
B. | only if you know the password. |
C. | to member functions of that class. |
D. | only to public members of the class. |
Answer» C. to member functions of that class. |
16. |
A member function can always access the data |
A. | in the object of which it is a member. |
B. | in the class of which it is a member. |
C. | in any object of the class of which it is a member. |
D. | in the public part of its class. |
Answer» A. in the object of which it is a member. |
17. |
Classes are useful because they |
A. | can closely model objects in the real world. |
B. | permit data to be hidden from other classes. |
C. | bring together all aspects of an entity in one place. |
D. | options a, b and c |
Answer» D. options a, b and c |
18. |
For the object for which it was called, a const member function |
A. | can modify both const and non-const member data. |
B. | can modify only const member data. |
C. | can modify only non-const member data. |
D. | can modify neither const nor non-const member data. |
Answer» D. can modify neither const nor non-const member data. |
19. |
Dividing a program into functions |
A. | is the key to object-oriented programming. |
B. | makes the program easier to conceptualize. |
C. | may reduce the size of the program. |
D. | option b and c |
Answer» D. option b and c |
20. |
An expression |
A. | usually evaluates to a numerical value. |
B. | may be part of a statement. |
C. | always occurs outside a function. |
D. | option a and b |
Answer» D. option a and b |
21. |
A variable of type char can hold the value 301. |
A. | true |
B. | false |
Answer» 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. |
A. | true |
B. | false |
Answer» B. false |
23. |
It’s perfectly all right to use variables of different data types in the same arithmetic expression. |
A. | true |
B. | false |
Answer» A. true |
24. |
A function’s single most important role is to |
A. | give a name to a block of code. |
B. | reduce program size. |
C. | accept arguments and provide a return value. |
D. | help organize a program into conceptual units. |
Answer» D. help organize a program into conceptual units. |
25. |
A function argument is |
A. | a variable in the function that receives a value from the calling program. |
B. | a way that functions resist accepting the calling program’s values. |
C. | a value sent to the function by the calling program. |
D. | a value returned by the function to the calling program. |
Answer» 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. |
A. | true |
B. | false |
Answer» B. false |
27. |
Which of the following can legitimately be passed to a function? |
A. | a constant |
B. | a variable |
C. | a structure |
D. | all of the above |
Answer» D. all of the above |
28. |
How many values can be returned from a function? |
A. | 0 |
B. | 1 |
C. | 2 |
D. | 3 |
Answer» 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. |
A. | true |
B. | false |
Answer» A. true |
30. |
When an argument is passed by reference |
A. | a variable is created in the function to hold the argument’s value. |
B. | the function cannot access the argument’s value. |
C. | a temporary variable is created in the calling program to hold the argument’s value. |
D. | the function accesses the argument’s original value in the calling program. |
Answer» D. the function accesses the argument’s original value in the calling program. |
31. |
Overloaded functions |
A. | are a group of functions with the same name. |
B. | all have the same number and types of arguments. |
C. | make life simpler for programmers. |
D. | a and c |
Answer» D. a and c |
32. |
A static local variable is used to |
A. | make a variable visible to several functions. |
B. | make a variable visible to only one function. |
C. | retain a value when a function is not executing. |
D. | b and c |
Answer» D. b and c |
33. |
In C++ there can be an array of four dimensions. |
A. | true |
B. | false |
Answer» A. true |
34. |
When an array name is passed to a function, the function |
A. | accesses exactly the same array as the calling program. |
B. | refers to the array using a different name than that used by the calling program. |
C. | refers to the array using the same name as that used by the calling program. |
D. | a and b |
Answer» D. a and b |
35. |
The compiler will complain if you try to access array element 14 in a 10-element array. |
A. | true |
B. | false |
Answer» B. false |
36. |
The extraction operator (>>) stops reading a string when it encounters a space. |
A. | true |
B. | false |
Answer» A. true |
37. |
You can read input that consists of multiple lines of text using |
A. | the normal cout <<combination. |
B. | the cin.get() function with one argument. |
C. | the cin.get() function with two arguments. |
D. | the cin.get() function with three arguments. |
Answer» D. the cin.get() function with three arguments. |
38. |
You should prefer C-strings to the Standard C++ string class in new programs. |
A. | true |
B. | false |
Answer» B. false |
39. |
Objects of the string class |
A. | are zero-terminated. |
B. | can be copied with the assignment operator. |
C. | do not require memory management. |
D. | both b and c |
Answer» D. both b and c |
40. |
Can destuctors be private in C++? |
A. | yes |
B. | no |
Answer» A. yes |
41. |
What is value of size? |
A. | 28 |
B. | 32 |
C. | 20 |
D. | 24 |
Answer» C. 20 |
42. |
What value will be printed for data.i? |
A. | 10 220.5 230.5 unpredictable value |
B. | 220 |
C. | 230.5 |
D. | unpredictable value |
Answer» D. unpredictable value |
43. |
What is the compilation error for this program? |
A. | each undeclared identifier is reported only once |
B. | cout and cin not declared in scope |
C. | invalid conversion from int to float |
D. | all of the above |
Answer» B. cout and cin not declared in scope |
44. |
What will be the output of the program? |
A. | 1 |
B. | default value |
C. | will not compile |
D. | none of the above |
Answer» C. will not compile |
45. |
What is the output of the program? |
A. | 0 0 |
B. | x = 0 y = 0 |
C. | 0 |
D. | compilation error |
Answer» D. compilation error |
46. |
Which function will change the state of the object? |
A. | only set() |
B. | only display() |
C. | display() and set() both |
D. | none of the above |
Answer» A. only set() |
47. |
What will be the output of the following program? |
A. | compilation error: display() cannot be accessed in application |
B. | compilation error:test class object cannot be accessed in function demo |
C. | compilation error: variable x is private in test |
D. | both a and b |
Answer» C. compilation error: variable x is private in test |
48. |
The only integer that can be assigned directly to a pointer is |
A. | 0 |
B. | -1 |
C. | 999 |
D. | -999 |
Answer» A. 0 |
49. |
Which of the following feature is not supported by C++? |
A. | exception handling |
B. | reflection |
C. | operator overloading |
D. | namespace |
Answer» B. reflection |
50. |
The operators that cannot be overloaded is |
A. | * |
B. | - |
C. | :: |
D. | () |
Answer» 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. |
A. | true |
B. | false |
Answer» 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. |
A. | structures |
B. | classes |
C. | objects |
D. | function |
Answer» B. classes |
53. |
Which of the following is FALSE about references in C++ |
A. | a reference must be initialized when declared |
B. | once a reference is created, it cannot be later made to reference another object; it cannot be reset |
C. | references cannot be null |
D. | references cannot refer to constant value |
Answer» D. references cannot refer to constant value |
54. |
What will be the output of following program?
|
A. | main started |
B. | main started hello from test() |
C. | hello from test() main started |
D. | compiler error: global objects are not allowed |
Answer» C. hello from test() main started |
55. |
Which of the following is true about constructors.
|
A. | all 1, 2, and 3 |
B. | only 1 and 3 |
C. | only 1 and 2 |
D. | only 2 and 3 |
Answer» B. only 1 and 3 |
56. |
Which of the following operators are overloaded by default by the compiler?
|
A. | both 1 and 2 |
B. | only 1 |
C. | only 2 |
D. | none of the two |
Answer» C. only 2 |
57. |
Which of the following is true about inline functions and macros. |
A. | inline functions do type checking for parameters, macros don't |
B. | macros cannot have return statement, inline functions can |
C. | macros are processed by pre-processor and inline functions are processed in later stages of compilation. |
D. | all of the above |
Answer» D. all of the above |
58. |
In C++, const qualifier can be applied to
|
A. | only 1, 2 and 3 |
B. | only 1, 2 and 4 |
C. | all |
D. | only 1, 3 and 4 |
Answer» C. all |
59. |
Which type is best suited to represent the logical values? |
A. | integer |
B. | boolean |
C. | character |
D. | all of the mentioned |
Answer» B. boolean |
60. |
The following is the C++ style comment |
A. | // |
B. | /*..*/ |
C. | – |
D. | none of above |
Answer» A. // |
61. |
Which of the following statements is false? |
A. | every c++ program must have a main(). |
B. | in c++, white spaces and carriage returns are ignored by the compiler. |
C. | c++ statements terminate with semicolon. |
D. | main() terminates with semicolon. |
Answer» D. main() terminates with semicolon. |
62. |
Functions can returns |
A. | arrays |
B. | references |
C. | objects |
D. | all of above |
Answer» D. all of above |
63. |
Which of the following control expressions are valid for an if statement? |
A. | an integer expression |
B. | a boolean expression |
C. | either a or b |
D. | neither a nor b |
Answer» 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;
|
A. | x=25, m=10, n=15 |
B. | x=27, m=10, n=15 |
C. | x=26, m=11, n=16 |
D. | x=27, m=11, n=16 |
Answer» C. x=26, m=11, n=16 |
65. |
Which of the following approach is adapted by C++? |
A. | top-down |
B. | bottom-up |
C. | right-left |
D. | left-right |
Answer» B. bottom-up |
66. |
Which of the following is the correct class of the object cout? |
A. | iostream |
B. | istream |
C. | ostream |
D. | ifstream |
Answer» C. ostream |
67. |
Which of the following functions are performed by a constructor? |
A. | construct a new class |
B. | construct a new object |
C. | construct a new function |
D. | initialize objects |
Answer» D. initialize objects |
68. |
Which of the following ways are legal to access a class data member using this pointer? |
A. | this->x |
B. | this.x |
C. | *this.x |
D. | *this-x |
Answer» A. this->x |
69. |
Which operator is having right to left associativity in the following? |
A. | array subscripting |
B. | function call |
C. | addition and subtraction |
D. | type cast |
Answer» D. type cast |
70. |
Which operator is having the highest precedence? |
A. | postfix |
B. | unary |
C. | shift |
D. | equality |
Answer» A. postfix |
71. |
#include <iostream>
|
A. | 35 |
B. | 20 |
C. | 25 |
D. | 30 |
Answer» B. 20 |
72. |
In procedural programming the focus in on …........... |
A. | data |
B. | structure |
C. | function |
D. | pointers |
Answer» C. function |
73. |
In object oriented programming the focus is on …....... |
A. | data |
B. | structure |
C. | function |
D. | pointers |
Answer» A. data |
74. |
Which of the following feature of procedure oriented program is false? |
A. | makes use of bottom up approach |
B. | functions share global data |
C. | the most fundamental unit of program is function |
D. | all of these |
Answer» A. makes use of bottom up approach |
75. |
Which of the following feature of object oriented program is false? |
A. | data and functions can be added easily |
B. | data can be hidden from outside world |
C. | object can communicate with each other |
D. | the focus is on procedures |
Answer» D. the focus is on procedures |
76. |
C++ was originally developed by …....... |
A. | donald knuth |
B. | bjarne sroustrups |
C. | dennis ritchie |
D. | none of these |
Answer» B. bjarne sroustrups |
77. |
Which of the following approach is adopted in C++? |
A. | top down |
B. | bottom up |
C. | horizontal |
D. | vertical |
Answer» B. bottom up |
78. |
Which feature of C++ contain the concept of super class and subclass? |
A. | class and object |
B. | encapsulation |
C. | abstraction |
D. | inheritance |
Answer» D. inheritance |
79. |
The main intention of using inheritance is …......... |
A. | to help in converting one data type to other |
B. | to hide the details of base class |
C. | to extend the capabilities of base class |
D. | to help in modular programming |
Answer» 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 …......... |
A. | data binding |
B. | data reusability |
C. | data encapsulation |
D. | none of these |
Answer» B. data reusability |
81. |
Which of the following data type does not return anything? |
A. | int |
B. | short |
C. | long |
D. | void |
Answer» D. void |
82. |
How many objects can be created from an abstract class? |
A. | zero |
B. | one |
C. | two |
D. | as many as we want |
Answer» A. zero |
83. |
Which of the following statements is correct for a static member function?
|
A. | only 1 is correct |
B. | only 2 is correct |
C. | both 1 and 2 are correct |
D. | both 1 and 2 are incorrect |
Answer» 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? |
A. | compile-time error |
B. | preprocessing error |
C. | runtime error |
D. | runtime exception |
Answer» A. compile-time error |
85. |
Which of the following interface determines how your program will be used by other program? |
A. | public |
B. | private |
C. | protected |
D. | none of these |
Answer» A. public |
86. |
What is the difference between struct and class in C++? |
A. | all members of a structure are public and structures don't have constructors and destructors |
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. |
C. | all members of a structure are public and structures don't have virtual functions |
D. | all above |
Answer» 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
|
A. | a non zero value |
B. | 0 |
C. | compile time error |
D. | runtime error |
Answer» A. a non zero value |
88. |
class Test { int x;
|
A. | 0 |
B. | garbage value |
C. | compile time error |
Answer» C. compile time error |
89. |
Which of the following is true? |
A. | all objects of a class share all data members of class |
B. | objects of a class do not share non-static members. every object has its own copy |
C. | objects of a class do not share codes of non-static methods, they have their own copy |
D. | none |
Answer» 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
|
A. | compiler error: cannot have two objects with same class name |
B. | compiler error in line "::t.get();" |
C. | compiles and runs fine |
Answer» 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. |
A. | 1 and 3 |
B. | 2 and 3 |
C. | 1 and 2 |
D. | all 1,2,3 |
Answer» C. 1 and 2 |
92. |
Predict the output?
|
A. | compile time error |
B. | garbage |
C. | 0 |
D. | 5 |
Answer» A. compile time error |
93. |
What happens when delete is used for a NULL pointer? int *ptr = NULL; delete ptr; |
A. | compile time error |
B. | run time error |
C. | no effect |
Answer» C. no effect |
94. |
Is it fine to call delete twice for a pointer?
|
A. | yes |
B. | no |
Answer» B. no |
95. |
Which of the followings is/are automatically added to every class, if we do not write our own. |
A. | copy constructor |
B. | assignment operator |
C. | a constructor without any parameter |
D. | all |
Answer» D. all |
96. |
When a copy constructor may be called? |
A. | when an object of the class is returned by value |
B. | when an object of the class is passed (to a function) by value as an argument |
C. | when an object is constructed based on another object of the same class |
D. | all |
Answer» D. all |
97. |
Output of following program?
|
A. | compile time error |
B. | run time error |
C. | constructor called |
Answer» A. compile time error |
98. |
#include<iostream> using namespace std; class Point {
|
A. | compiler error |
B. | constructor called constructor called |
C. | constructor called |
Answer» C. constructor called |
99. |
#include<iostream> using namespace std;
|
A. | compiler error |
B. | 10 followed by garbage value |
C. | 10 10 |
D. | 10 0 |
Answer» D. 10 0 |
Done Reading?