

MCQOPTIONS
Saved Bookmarks
This section includes 134 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. |
Which of the followings are false statements about Local class? 1. A local class type name can only be used in the enclosing function 2. All the methods of Local classes must be defined inside the class only 3. A Local class can contain static data members. 4. A Local class may contain static functions. 5. Non-static variables of the enclosing function are not accessible inside local classes. 6. Local classes cannot access global types, variables and functions. |
A. | Only 1,3 |
B. | Only 3, 6 |
C. | Only 2 , 4 , 6 |
D. | None of these |
Answer» C. Only 2 , 4 , 6 | |
2. |
Which of the followings are true about constructors? 1. A class can have more than one constructor. 2. They can be inherited. 3. Their address can be referred. 4. Constructors cannot be declared in protected section of the class. 5. Constructors cannot return values. |
A. | Only 1,2,4 |
B. | 1,2,4,5 |
C. | 1,3,5 |
D. | 1,4,5 |
Answer» E. | |
3. |
Which of the followings are true about Virtual functions? |
A. | They must be non-static member function of the class |
B. | They cannot be friends |
C. | Constructor Functions cannot be virtual |
D. | All of these |
Answer» E. | |
4. |
Which of the followings is/are not a manipulator/s ? 1. flush 2. base 3. ends 4. oct 5. bin 6. skipws |
A. | Only 1, 6 |
B. | Only 1,4,6 |
C. | Only 1,3,6 |
D. | Only 2,5 |
Answer» E. | |
5. |
Which of the followings is/are not false about friend function ? 1. It can be called / invoked with class object. 2. It has objects as arguments. 3. It can have built-in types as arguments. 4. It must declared only in public part of a class. 5. It does not have this pointer as an argument. |
A. | Only 2,4 |
B. | Only 1,2,5 |
C. | Only 2,3,5 |
D. | All of these |
Answer» D. All of these | |
6. |
Which of the followings is/are not keyword/s in CPP? 1. asm 2. boolean 3. mutable 4. export 5. constant_cast |
A. | Only 5 |
B. | Only 1 and 4 |
C. | Only 1,2 and 5 |
D. | Only 2 and 5 |
Answer» E. | |
7. |
Which one is suitable syntax for function template? |
A. | template< class T> return_type Function_Name(parameters) |
B. | template< typename T> return_type Function_Name(parameters) |
C. | both a and b |
D. | None of these |
Answer» D. None of these | |
8. |
While redefining a virtual function in the derived class, if its prototype is changed then ___________________ . |
A. | It will be overloaded by the compiler |
B. | Its virtual nature will be lost |
C. | both a and b |
D. | Compiler will generate “Prototype mismatch error” |
Answer» D. Compiler will generate “Prototype mismatch error” | |
9. |
Which of the following statements are true about Catch handler? 1. It must be placed immediately after try block T. 2. It can have multiple parameters. 3. There must be only one catch handler for every try block. 4. There can be multiple catch handler for a try block T. 5. Generic catch handler can be placed anywhere after try block. |
A. | Only 1, 4, 5 |
B. | Only 1, 2, 3 |
C. | Only 1, 4 |
D. | Only 1, 2 |
Answer» D. Only 1, 2 | |
10. |
Which of the following statements are not true about destructor? 1. It is invoked when object goes out of the scope 2. Like constructor, it can also have parameters 3. It can be virtual 4. It can be declared in private section 5. It bears same name as that of the class and precedes Lambda sign. |
A. | Only 2, 3, 5 |
B. | Only 2, 3, 4 |
C. | Only 2, 4, 5 |
D. | Only 3, 4, 5 |
Answer» D. Only 3, 4, 5 | |
11. |
Which of the following operator is used to release the dynamically allocated memory in CPP? |
A. | remove |
B. | free |
C. | delete |
D. | both b and c |
Answer» D. both b and c | |
12. |
Which of the following manipulator is used for the representing octal equivalent of a given decimal number? |
A. | oct |
B. | setbase(8) |
C. | tobase(8) |
D. | both a and b |
E. | all a, b, c |
Answer» E. all a, b, c | |
13. |
Which of the following is/are valid ways to allocate memory for an integer by dynamic memory allocation in CPP? |
A. | int *p = new int(100); |
B. | int *p; p = new int; *p = 100; |
C. | int *p = NULL; p = new int; *p=100; |
D. | Only 1,2 |
E. | All of these |
Answer» F. | |
14. |
Which of the following is the perfect set of operators that can’t be overloaded in CPP ? |
A. | +=, ?, :: , >> |
B. | >>, <<, ?, *, sizeof() |
C. | :: , . , .* , ?: |
D. | :: , ->, * , new, delete |
Answer» D. :: , ->, * , new, delete | |
15. |
Which of the following is not used to seek a file pointer? |
A. | ios::cur |
B. | ios::set |
C. | ios::end |
D. | ios::beg |
Answer» C. ios::end | |
16. |
Which of the following is not a file opening mode ____ . |
A. | ios::ate |
B. | ios::nocreate |
C. | ios::noreplace |
D. | ios::truncate |
Answer» E. | |
17. |
Which of the following is not a false statement about new operator? |
A. | It can’t be overloaded. |
B. | It returns garbage value when memory allocation fails. |
C. | It automatically computes the size of the data object. |
D. | All of these |
Answer» D. All of these | |
18. |
Which of the following is not a casting operator in CPP? |
A. | explicit_cast |
B. | static_cast |
C. | dynamic_cast |
D. | reinterpret_cast |
Answer» B. static_cast | |
19. |
Which of the following is CPP style type-casting? |
A. | per = total/(float)m |
B. | per = total/float(m) |
C. | per = (float)total/m |
D. | None of these |
Answer» C. per = (float)total/m | |
20. |
Which of the following best defines the syntax for template function ? |
A. | Template |
B. | Template return_type Function_Name(Parameters) |
C. | Both a and b |
D. | None of these |
Answer» D. None of these | |
21. |
Which of the following are true about static member function? 1. They can access non-static data members. 2. They can call only other static member functions. 3. They can access global functions and data. 4. They can have this pointer. 5. They cannot be declared as const or volatile. |
A. | Only 2 |
B. | Only 2,5 |
C. | Only 2,3,4,5 |
D. | Only 2 , 3 , 5 |
E. | All of these |
Answer» E. All of these | |
22. |
Which of the following are member dereferencing operators in CPP? 1. * 2. :: 3. ->* 4. ::* 5. -> |
A. | Only 1, 3, 4 |
B. | Only 1 and 5 |
C. | Only 3 and 4 |
D. | Only 3,4,5 |
Answer» B. Only 1 and 5 | |
23. |
When overloading unary operators using Friend function,it requires_____ argument/s. |
A. | Zero |
B. | One |
C. | Two |
D. | None of these. |
Answer» C. Two | |
24. |
When base class is derived in protected mode, then_____________ . 1. public members of base class become private members of derived class. 2. public members of base class become protected members of derived class. 3. public members of base class become public members of derived class. 4. protected members of base class become protected members of derived class. 5. protected members of base class become private members of derived class. 6. protected members of base class become public members of |
A. | Only 1, 5 |
B. | Only 1, 6 |
C. | Only 2, 6 |
D. | Only 2, 4 |
Answer» E. | |
25. |
When a class is defined inside any function or block, it is called ___________ . |
A. | Nested class |
B. | Block class |
C. | Local class |
D. | It is not possible |
Answer» D. It is not possible | |
26. |
When a child class inherits traits from more than one parent class, this type of inheritance is called _______________ inheritance. |
A. | Hierarchical |
B. | Hybrid |
C. | Multilevel |
D. | Multiple |
Answer» E. | |
27. |
When a base class is privately inherited by the derived class, then_____________ . |
A. | protected members of the base class become private members of derived class |
B. | public members of the base class become private members of derived class |
C. | both a and b |
D. | only b |
Answer» D. only b | |
28. |
What is the difference between protected and private access specifiers in inheritance? |
A. | private member is not inheritable and not accessible in derived class. |
B. | protected member is inheritable and also accessible in derived class. |
C. | Both are inheritable but private is accessible in the derived class. |
D. | Both are inheritable but protected is not accessible in the derived class. |
Answer» C. Both are inheritable but private is accessible in the derived class. | |
29. |
We can prevent a function from throwing any exceptions. |
A. | True |
B. | False |
Answer» B. False | |
30. |
We can create objects of the abstract class. |
A. | True |
B. | False |
Answer» C. | |
31. |
We can initialize a value of static variable of a class only when its object is created. No other initialization is permitted. |
A. | True |
B. | False |
Answer» C. | |
32. |
Using friend operator function, following perfect set of operators may not be overloaded. |
A. | 0 |
B. | <<, = = , [ ] , >> |
C. | ?, = , ( ) , ++ |
D. | None of these |
Answer» B. <<, = = , [ ] , >> | |
33. |
To perform File I/O operations, we must use _____________ header file. |
A. | < ifstream> |
B. | < ofstream> |
C. | < fstream> |
D. | Any of these |
Answer» D. Any of these | |
34. |
To create an output stream, we must declare the stream to be of class ___________ . |
A. | ofstream |
B. | ifstream |
C. | iostream |
D. | None of these |
Answer» B. ifstream | |
35. |
Throwing an unhandled exception causes standard library function then _________ to be invoked. |
A. | stop() |
B. | aborted() |
C. | terminate() |
D. | Abandon() |
Answer» D. Abandon() | |
36. |
The purpose of explicit keyword is to tell the compiler that a certain constructor may not be used to implicitly cast an expression to its class type. |
A. | True |
B. | False |
Answer» B. False | |
37. |
The explicit keyword is an optional decoration for the constructors that takes exactly_____argument. |
A. | No argument |
B. | Two |
C. | Three |
D. | One |
Answer» E. | |
38. |
The derivation of Child class from Base class is indicated by ____ symbol. |
A. | :: |
B. | : |
C. | ; |
D. | | |
Answer» C. ; | |
39. |
The CPP compiler supports automatic type conversions for the user defined datatypes. |
A. | True |
B. | False |
Answer» C. | |
40. |
The code of statements which may cause abnormal termination of the program should be written under_________ block. |
A. | Try |
B. | catch |
C. | Finally |
D. | None of these |
Answer» B. catch | |
41. |
Scope resolution operator is used______ . |
A. | to resolve the scope of global variables only |
B. | to resolve the scope of functions of the classes only |
C. | to resolve scope of global variables as well as functions of the classes |
D. | None of these |
Answer» D. None of these | |
42. |
Runtime polymorphism is achieved only when a virtual function is accessed through a pointer to the base class. |
A. | True |
B. | False |
Answer» B. False | |
43. |
Run time polymorphism can be achieved with______ . |
A. | Virtual Base class |
B. | Container class |
C. | Virtual function |
D. | Both a and c |
Answer» D. Both a and c | |
44. |
Return type of uncaught_exception() is ________________ . |
A. | int |
B. | bool |
C. | char * |
D. | double |
Answer» C. char * | |
45. |
Reusability of the code can be achieved in CPP through ______ . |
A. | Polymorphism |
B. | Encapsulation |
C. | Inheritance |
D. | Both a and c |
Answer» D. Both a and c | |
46. |
____________ refers to the act of representing only essential features without including the background details. |
A. | Data Hiding |
B. | Data Encapsulation |
C. | Data Abstraction |
D. | All of these |
Answer» D. All of these | |
47. |
Public data members and member functions of the class are accessible ONLY to the member functions of that class. |
A. | True |
B. | False |
Answer» C. | |
48. |
Private members of the class are not inheritable. |
A. | True |
B. | False |
Answer» C. | |
49. |
Private members of the class are accessible only to the members of the same class. |
A. | True |
B. | False |
Answer» C. | |
50. |
Only functions of the class can access the data of the class and they(functions) provides the interface between data, objects and the program. This kind isolation of the data from direct access by the program is called _______________ . |
A. | Data Abstraction |
B. | Data Hiding |
C. | Data Binding |
D. | Data Encapsulation |
Answer» C. Data Binding | |