

MCQOPTIONS
Saved Bookmarks
This section includes 542 Mcqs, each offering curated multiple-choice questions to sharpen your Computer Science knowledge and support exam preparation. Choose a topic below to get started.
1. |
xample obj = new Example (1,2,3); |
A. | constructor 2 |
B. | constructor 4 |
C. | constrcutor 1 |
D. | type mismatch error |
Answer» C. constrcutor 1 | |
2. |
How to declare operator function? |
A. | operator operator sign |
B. | operator |
C. | operator sign |
D. | none of the mentioned |
Answer» B. operator | |
3. |
Which of the following operators below allow to define the member functions of a class outside the class? |
A. | :: |
B. | ? |
C. | ?? |
D. | % |
Answer» E. | |
4. |
What is the implicit pointer that is passed as the first argument for nonstatic member functions? |
A. | ‘self’ pointer |
B. | std::auto_ptr pointer |
C. | ‘myself’ pointer |
D. | ‘this’ pointer |
Answer» E. | |
5. |
Statement scanf(“%d”,80); |
A. | assign an integer to variable i |
B. | give an error message |
C. | print the value of i |
D. | assign an float to variable i |
Answer» B. give an error message | |
6. |
What is deep copy? |
A. | a deep copy creates a copy of the dynamically allocated objects too. |
B. | a deep copy just copies the values of the data as they are. |
C. | a deep copy creates a copy of the statically allocated objects too |
D. | both b and c above |
Answer» C. a deep copy creates a copy of the statically allocated objects too | |
7. |
Inline functions are invoked at the time of |
A. | run time |
B. | compile time |
C. | depends on how it is invoked |
D. | both b and c above |
Answer» D. both b and c above | |
8. |
Which of the following is the most general exception handler that catches exception of ‘any type’? |
A. | catch(std::exception) |
B. | catch(std::any_exception) |
C. | catch(…) |
D. | catch() |
Answer» D. catch() | |
9. |
Value of ix+j, if i,j are integer type and ix long type would be |
A. | integer |
B. | float |
C. | long integer |
D. | double percision |
Answer» C. long integer | |
10. |
How do we declare an ‘interface’ class? |
A. | by making all the methods pure virtual in a class |
B. | by making all the methods abstract using the keyword ‘abstract’ in a class |
C. | by declaring the class as interface with the keyword ‘interface’ |
D. | it is not possible to create interface class in c++ |
Answer» B. by making all the methods abstract using the keyword ‘abstract’ in a class | |
11. |
class derived: public base1, public base2 { } is an example of |
A. | polymorphic inheritance |
B. | multilevel inheritance |
C. | hierarchical inheritance |
D. | multiple inheritance |
Answer» C. hierarchical inheritance | |
12. |
Which of the following correctly describes the meaning of ‘namespace’ feature in C++? |
A. | namespaces refer to the memory space allocated for names used in a program |
B. | namespaces refer to space between teh names in a program |
C. | namespaces refer to space between the names in a program |
D. | namespaces provide facilities for organizing the names in a program to avoid name clashes |
Answer» E. | |
13. |
Which of the following correctly describes the meaning of‘namespace’ feature in C++? |
A. | namespaces refer to the memory space allocated for names used in a program |
B. | namespaces refer to space between the names in a program |
C. | namespaces refer to packing structure of classes in a program. |
D. | namespaces provide facilities for organizing the names in aprogram to avoid name clashes. |
Answer» B. namespaces refer to space between the names in a program | |
14. |
The default access level assigned to members of a class is ___________ |
A. | private |
B. | public |
C. | protected |
D. | needs to be assigned |
Answer» D. needs to be assigned | |
15. |
The two types of file structure existing in VSAM file are |
A. | key sequenced structure, entry sequenced structure |
B. | key sequence structure, exit sequenced structure |
C. | entry sequence structure, exit sequenced structure |
D. | none of above |
Answer» D. none of above | |
16. |
Originally ‘C’ was developed as: |
A. | system programming language |
B. | general purpose language |
C. | data processing language |
D. | none of above |
Answer» D. none of above | |
17. |
The conditional compilation |
A. | it is taken care of by the compiler |
B. | it is setting the compiler option conditionally |
C. | it is compiling a program based on a condition |
D. | none of above |
Answer» E. | |
18. |
‘Prime area’ in context of file system is defined as |
A. | it is memory area created by operating system |
B. | it is an area into which data records are written |
C. | it is the main area of a web page |
D. | none of the above |
Answer» C. it is the main area of a web page | |
19. |
A direct access file is: |
A. | a file in which recoreds are arranged in a way they are inserted in a file |
B. | a file in which records are arranged in a particular order |
C. | files which are stored on a direct access storage medium |
D. | none of the above |
Answer» D. none of the above | |
20. |
Which one of the following is not a valid reserved keyword in C++ |
A. | explicit |
B. | public |
C. | implicit |
D. | private |
Answer» D. private | |
21. |
What does STL stand for? |
A. | simple template library |
B. | standard template library |
C. | static type library |
D. | single type-based library |
Answer» C. static type library | |
22. |
Which of the STL containers store the elements contiguously (in adjacent memory locations)? |
A. | std::vector |
B. | std::list |
C. | std::map |
D. | std::set |
Answer» D. std::set | |
23. |
What’s wrong? for (int k = 2, k <=12, k++) |
A. | the increment should always be ++k |
B. | the variable must always be the letter i when using a for loop |
C. | there should be a semicolon at the end of the statement |
D. | the commas should be semicolons |
Answer» C. there should be a semicolon at the end of the statement | |
24. |
What’s wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6); |
A. | the question mark should be an equal sign |
B. | the first semicolon should be a colon |
C. | there are too many variables in the statement |
D. | the conditional operator is only used with apstrings |
Answer» E. | |
25. |
What’s wrong? while( (i < 10) && (i > 24)) |
A. | the logical operator && cannot be used in a test condition |
B. | the while loop is an exit-condition loop |
C. | the test condition is always false |
D. | the test condition is always true |
Answer» E. | |
26. |
Which of the following correctly describes C++ language? |
A. | statically typed language |
B. | dynamically typed language |
C. | both statically and dynamically typed language |
D. | type-less language |
Answer» E. | |
27. |
Which of the following is a valid destructor of the class name “Country” |
A. | int ~country() |
B. | void country() |
C. | int ~country(country obj) |
D. | void ~country() |
Answer» C. int ~country(country obj) | |
28. |
When is std::bad_alloc exception thrown? |
A. | when new operator cannot allocate memory |
B. | when alloc function fails |
C. | when type requested for new operation is considered bad, thisexception is thrown |
D. | object |
Answer» E. | |
29. |
If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)? |
A. | const x* const |
B. | x* const |
C. | x* |
D. | x& |
Answer» E. | |
30. |
The contents of two pointers that point to adjacent of type float differ by |
A. | one bytes |
B. | two bytes |
C. | three bytes |
D. | four bytes |
Answer» E. | |
31. |
Evaluate the following expression: 4 >6 || 10 < 2 * 6 |
A. | true |
B. | false |
Answer» B. false | |
32. |
A pattern for creating an object is called a(n) _____ |
A. | class |
B. | attributes |
C. | private |
D. | public |
Answer» B. attributes | |
33. |
You can override a class's inherited access to make an individual member's access more ______ |
A. | liberal |
B. | conservative |
C. | either (a) or (b) |
D. | neither (a) nor (b) |
Answer» C. either (a) or (b) | |
34. |
Which of the following statements declares a one-dimensional Character array named item that consists of five elements? |
A. | char item[0 to 4] = ""; |
B. | char item[0 to 5] = ""; |
C. | char item[4] = ""; |
D. | char item[5] = ""; |
Answer» E. | |
35. |
The exclusive OR operator gives the result 1 when |
A. | both the bits are 0 |
B. | one bit is 0 and the other is 1 |
C. | both the bits are 1 |
D. | no hard and fast rule |
Answer» C. both the bits are 1 | |
36. |
The base class for most stream classes is the _____ class |
A. | ios |
B. | out |
C. | in |
D. | app |
Answer» B. out | |
37. |
The best functions have _____ |
A. | high cohesion and tight coupling |
B. | high cohesion and loose coupling |
C. | low cohesion and tight coupling |
D. | low cohesion and loose coupling |
Answer» C. low cohesion and tight coupling | |
38. |
An expression |
A. | is a collection of data objects and operators that can be evaluated to a single value |
B. | is a name that substitutes for a sequence of characters |
C. | causes the computer to carry out some action |
D. | All of the above |
Answer» B. is a name that substitutes for a sequence of characters | |
39. |
The two operators && an || are |
A. | arithmetic operators |
B. | equality operators |
C. | logical operators |
D. | relational operators |
Answer» D. relational operators | |
40. |
The extraction operator >> is a(n) _____ |
A. | overloaded function |
B. | C++ class |
C. | C++ object |
D. | static reference variables |
Answer» B. C++ class | |
41. |
Which of the following statements will display the word "Hello" on the computer screen? |
A. | cin << "Hello"; |
B. | cin >> "Hello"; |
C. | cout << "Hello"; |
D. | cout >> "Hello"; |
Answer» D. cout >> "Hello"; | |
42. |
Using a statement at the wrong time or with an inappropriate object creates a |
A. | logical error |
B. | syntax error |
C. | compiler error |
D. | language error |
Answer» B. syntax error | |
43. |
Which functions do not have a this pointer? |
A. | access functions |
B. | inspector functions |
C. | member functions |
D. | static functions |
Answer» E. | |
44. |
The last statement in a value-returning function is always _____ |
A. | }; |
B. | result expression; |
C. | return; |
D. | return expression; |
Answer» E. | |
45. |
In a C++ program, which of the following can be thrown? |
A. | scalar variables |
B. | programmer-defined objects |
C. | both (a) and (b) |
D. | neither (a) nor (b) |
Answer» C. both (a) and (b) | |
46. |
A pointer to void can hold pointers to |
A. | char type |
B. | int type |
C. | float type |
D. | any data type |
Answer» E. | |
47. |
A constructor initialization list is preceded by _____ |
A. | a semicolon |
B. | a colon |
C. | two colons |
D. | a space |
Answer» C. two colons | |
48. |
Function templates _____________ |
A. | must have exactly one parameter |
B. | may have more than one parameter as long as they are of the same type |
C. | may have more than one parameter of any type |
D. | may not have parameters |
Answer» D. may not have parameters | |
49. |
You invoke a function with a function |
A. | call |
B. | declaration |
C. | definition |
D. | prototype |
Answer» B. declaration | |
50. |
A constructor initialization list is preceded by |
A. | a. semicolon |
B. | a colon |
C. | two colons |
D. | a space |
Answer» C. two colons | |