MCQOPTIONS
Saved Bookmarks
This section includes 1331 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
| 851. |
The following can be declared as friend in a class |
| A. | an object |
| B. | a class |
| C. | a public data member |
| D. | a private data member |
| Answer» C. a public data member | |
| 852. |
A white space is : |
| A. | blank space |
| B. | new line |
| C. | tab |
| D. | all of the above |
| Answer» E. | |
| 853. |
What will be the output of following program? #include void main() { float x; x=(float)9/2; cout |
| A. | 4.5 |
| B. | 4.0 |
| C. | 4 |
| D. | 5 |
| Answer» B. 4.0 | |
| 854. |
A constructor |
| A. | Constructs new data type |
| B. | Enables the initialization of an object as it is created |
| C. | Obtain memory for a new variable |
| D. | None of the above |
| Answer» C. Obtain memory for a new variable | |
| 855. |
What will be the value of d if d is a float after the operation d = 2 / 7.0? |
| A. | 0 |
| B. | 0.2857 |
| C. | Cannot be determined |
| D. | None of the above |
| Answer» C. Cannot be determined | |
| 856. |
Which of the following shows the correct hierarchy of arithmetic operations in C ? |
| A. | / + * - |
| B. | * - / + |
| C. | + - / * |
| D. | * / + - |
| Answer» E. | |
| 857. |
The actual source code for implementing a template function is created when |
| A. | The declaration of function appears. |
| B. | The function is invoked. |
| C. | The definition of the function appears. |
| D. | None of the above. |
| Answer» C. The definition of the function appears. | |
| 858. |
Which of the following expressions is illegal? |
| A. | (10|6). |
| B. | (false && true) |
| C. | bool (x) = (bool)10; |
| D. | float y = 12.67; |
| Answer» D. float y = 12.67; | |
| 859. |
Consider the following class definitions: class a { }; class b: protected a { }; What happens when we try to compile this class? |
| A. | Will not compile because class body of a is not defined. |
| B. | Will not compile because class body of b is not defined. |
| C. | Will not compile because class a is not public inherited. |
| D. | Will compile successfully. |
| Answer» E. | |
| 860. |
The major goal of inheritance in c++ is: |
| A. | To facilitate the conversion of data types. |
| B. | To help modular programming. |
| C. | To extend the capabilities of a class. |
| D. | To hide the details of base class. |
| Answer» D. To hide the details of base class. | |
| 861. |
Which of the following will produce a value 10 if x = 9.7? |
| A. | floor(x) |
| B. | abs(x) |
| C. | log(x) |
| D. | ceil(x) |
| Answer» E. | |
| 862. |
What will be the values of x, m and n after the execution of the following statements? int x, m, n; m = 10; n = 15; x = ++m + n++; |
| A. | x=25, m=10, n=15 |
| B. | x=26, m=11, n=16 |
| C. | x=27, m=11, n=16 |
| D. | x=27, m=10, n=15 |
| Answer» C. x=27, m=11, n=16 | |
| 863. |
A class defined within another class is: |
| A. | Nested class |
| B. | Inheritance |
| C. | Containership |
| D. | Encapsulation |
| Answer» B. Inheritance | |
| 864. |
What is the output of given code fragment? int f=1, i=2; while(++i |
| A. | 12 |
| B. | 24 |
| C. | 6 |
| D. | 3 |
| Answer» B. 24 | |
| 865. |
Name the header file to be included for the use of built in function isalnum() |
| A. | string.h |
| B. | process.h |
| C. | ctype.h |
| D. | dos.h |
| Answer» D. dos.h | |
| 866. |
Which of the following is not the characteristic of constructor. |
| A. | They should be declared in the public section. |
| B. | They do not have return type. |
| C. | They can not be inherited. |
| D. | They can be virtual. |
| Answer» E. | |
| 867. |
To convert from a user defined class to a basic type, you would most likely use. |
| A. | A built-in conversion function. |
| B. | A one-argument constructor. |
| C. | A conversion function that’s a member of the class. |
| D. | An overloaded ‘=‘ operator. |
| Answer» D. An overloaded ‘=‘ operator. | |
| 868. |
The statement f1.write((char*)&obj1, sizeof(obj1)); |
| A. | writes the member function of obj1 to f1. |
| B. | Writes the data in obj1 to f1. |
| C. | Writes the member function and the data of obj1 to f1. |
| D. | Writes the address of obj1 to f1. |
| Answer» C. Writes the member function and the data of obj1 to f1. | |
| 869. |
We can output text to an object of class ostream using the insertion operator |
| A. | the ostream class is a stream |
| B. | the insertion operator works with all classes. |
| C. | we are actually outputting to cout. |
| D. | the insertion operator is overloaded in ostream. |
| Answer» E. | |
| 870. |
Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2? |
| A. | class d : public b1, public b2 |
| B. | class d : class b1, class b2 |
| C. | class d : public b1, b2 |
| D. | class d : b1, b2 |
| Answer» B. class d : class b1, class b2 | |
| 871. |
. A template class |
| A. | is designed to be stored in different containers |
| B. | works with different data types |
| C. | generates objects which must be identical |
| D. | generates classes with different numbers of member functions. |
| Answer» C. generates objects which must be identical | |
| 872. |
The purpose for mode “w+b” in file operation is |
| A. | create a binary file for write |
| B. | create a binary file for read/write |
| C. | open a binary file for writing |
| D. | open a binary file for reading/writing |
| Answer» C. open a binary file for writing | |
| 873. |
A static function |
| A. | should be called when an object is destroyed. |
| B. | is closely connected with and individual object of a class. |
| C. | can be called using the class name and function name. |
| D. | is used when a dummy object must be created. |
| Answer» D. is used when a dummy object must be created. | |
| 874. |
A pure virtual function is a virtual function that |
| A. | has no body |
| B. | returns nothing |
| C. | is used in base class |
| D. | both (A) and (C) |
| Answer» E. | |
| 875. |
If there is a pointer p to object of a base class and it contains the address of an object of a derived class and both classes contain a virtual member function abc(), then the statement p->abc(); will cause the version of abc() in the ................. class to be executed. |
| A. | Base Class |
| B. | Derived class |
| C. | Produces compile time error |
| D. | produces runtime error |
| Answer» C. Produces compile time error | |
| 876. |
An array element is accessed using |
| A. | a FIFO approach |
| B. | an index number |
| C. | the operator |
| D. | a member name |
| Answer» C. the operator | |
| 877. |
RunTime polymorphism is achieved by ................. |
| A. | friend function |
| B. | virtual function |
| C. | operator overloading |
| D. | function overloading |
| Answer» C. operator overloading | |
| 878. |
A library function exit() causes an exit from |
| A. | the loop in which it occurs |
| B. | the block in which it occurs |
| C. | the function in which it occurs |
| D. | the program in which it occurs |
| Answer» E. | |
| 879. |
Which of the statements is true in a protected derivation of a derived class from a base class? |
| A. | Private members of the base class become protected members of the derived class |
| B. | Protected members of the base class become public members of the derived class |
| C. | Public members of the base class become protected members of the derived class |
| D. | Protected derivation does not affect private and protected members of the derived class. |
| Answer» D. Protected derivation does not affect private and protected members of the derived class. | |
| 880. |
main ( ) is an example of |
| A. | library function |
| B. | user defined function |
| C. | header |
| D. | statement |
| Answer» B. user defined function | |
| 881. |
The output of the following code is a = 5; a |
| A. | 5 |
| B. | 6 |
| C. | 2 |
| D. | 3 |
| Answer» B. 6 | |
| 882. |
How many constructors can a class have? |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | any number |
| Answer» E. | |
| 883. |
Function templates can accept |
| A. | any type of parameters |
| B. | only one parameter |
| C. | only parameters of the basic type |
| D. | only parameters of the derived type |
| Answer» D. only parameters of the derived type | |
| 884. |
A pointer to the base class can hold address of |
| A. | only base class object |
| B. | only derived class object |
| C. | base class object as well as derived class object |
| D. | None of the above |
| Answer» D. None of the above | |
| 885. |
Exception handling is targeted at |
| A. | Run-time error |
| B. | Compile time error |
| C. | Logical error |
| D. | All of the above. |
| Answer» B. Compile time error | |
| 886. |
Which of the following statements is NOT valid about operator overloading? |
| A. | Only existing operators can be overloaded. |
| B. | Overloaded operator must have at least one operand of its class type. |
| C. | The overloaded operators follow the syntax rules of the original operator. |
| D. | none of the above. |
| Answer» E. | |
| 887. |
Which of the following is false for cin? |
| A. | It represents standard input. |
| B. | It is an object of istream class. |
| C. | It is a class of which stream is an object. |
| D. | Using cin the data can be read from user’s terminal. |
| Answer» D. Using cin the data can be read from user’s terminal. | |
| 888. |
Data members which are static |
| A. | cannot be assigned a value |
| B. | can only be used in static functions |
| C. | cannot be defined in a Union |
| D. | can be accessed outside the class |
| Answer» C. cannot be defined in a Union | |
| 889. |
Within a switch statement |
| A. | Continue can be used but Break cannot be used |
| B. | Continue cannot be used but Break can be used |
| C. | Both Continue and Break can be used |
| D. | Neither Continue nor Break can be used |
| Answer» B. Continue cannot be used but Break can be used | |
| 890. |
The expression, a = 30 * 1000 + 2768 ; evaluates to |
| A. | 32768 |
| B. | -32768 |
| C. | 113040 |
| D. | 0 |
| Answer» B. -32768 | |
| 891. |
The operator |
| A. | must be a member function |
| B. | must be a non member function |
| C. | can be both (A) & (B) above |
| D. | cannot be overloaded |
| Answer» D. cannot be overloaded | |
| 892. |
for (; ;) |
| A. | means the test which is done using some expression is always true |
| B. | is not valid |
| C. | will loop forever |
| D. | should be written as for( ) |
| Answer» D. should be written as for( ) | |
| 893. |
Declaration of a pointer reserves memory space |
| A. | for the object. |
| B. | for the pointer. |
| C. | both for the object and the pointer. |
| D. | none of these. |
| Answer» C. both for the object and the pointer. | |
| 894. |
In multiple inheritance |
| A. | the base classes must have only default constructors |
| B. | cannot have virtual functions |
| C. | can include virtual classes |
| D. | None of the above. |
| Answer» D. None of the above. | |
| 895. |
It is possible to declare as a friend |
| A. | a member function |
| B. | a global function |
| C. | a class |
| D. | all of the above |
| Answer» E. | |
| 896. |
Which statement gets affected when i++ is changed to ++i? |
| A. | i = 20; i++; |
| B. | for (i = 0; i<20; i++) { } |
| C. | a = i++; |
| D. | while (i++ = 20) cout <<i; |
| Answer» B. for (i = 0; i<20; i++) { } | |
| 897. |
If you wanted to sort many large objects or structures, it would be most efficient to |
| A. | place them in an array & sort the array. |
| B. | place pointers to them in an array & sort the array. |
| C. | place them in a linked list and sort the linked list. |
| D. | place references to them in an array and sort the array. |
| Answer» D. place references to them in an array and sort the array. | |
| 898. |
this pointer |
| A. | implicitly points to an object. |
| B. | can be explicitly used in a class. |
| C. | can be used to return an object. |
| D. | All of the above. |
| Answer» E. | |
| 899. |
Use of virtual functions implies |
| A. | overloading. |
| B. | overriding. |
| C. | static binding. |
| D. | dynamic binding. |
| Answer» E. | |
| 900. |
Additional information sent when an exception is thrown may be placed in |
| A. | the throw keyword. |
| B. | the function that caused the error. |
| C. | the catch block. |
| D. | an object of the exception class. |
| Answer» D. an object of the exception class. | |