Object Oriented Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Object Oriented Programming MCQ (Multiple Choice Questions)

 Que- Can data members be passed to a function using the object? 

a. Yes, it can be passed only inside class functions 

b. Yes, only if the data members are public and are being passed to a function outside the class 

c. No, can't be passed outside the class 

d. No, can't be done 


Ans- Yes, only if the data members are public and are being passed to a function outside the class  


Que- What exactly is passed when an object is passed by reference? 

a. The original object name 

b. The original object class name 

c. The exact address of the object in memory 

d. The exact address of data members 


Ans- The exact address of the object in memory  


Que- If the object is not to be passed to any function but the values of the object have to be used then: 

a. The data members should be passed separately 

b. The data members and member functions have to be passed separately 

c. The values should be present in other variables 

d. The object must be passed 


Ans- The data members should be passed separately  


Que- Which among the following is true? 

a. More than one object can't be passed to a function 

b. Any number of objects can be passed to a function 

c. Objects can't be passed, only data member values can be passed 

d. Objects should be passed only if those are public in class 


Ans- Any number of objects can be passed to a function  


Que- In which type is new memory location will be allocated? 

a. Only in pass by reference 

b. Only in pass by value 

c. Both in pass by reference and value 

d. Depends on the code 


Ans- Only in pass by value  


Que- In which of the following way(s) can the object be returned from a function? 

a. Can only be returned by value 

b. Can only be returned by reference 

c. Can be returned either by value or reference 

d. Can neither be returned by value nor by reference 


Ans- Can be returned either by value or reference  


Que- Whenever an object is returned by value ____________________ 

a. A temporary object is created 

b. Temporary object is not created 

c. Temporary object may or may not be created 

d. New permanent object is created 


Ans- A temporary object is created  


Que- Where the temporary objects (created while return by value) are created? 

a. Outside the function scope 

b. Within the function 

c. Inside the main function 

d. Inside the calling function 


Ans- Within the function  


Que- Which is the correct syntax for returning an object by value? 

a. void functionName ( ){ } 

b. object functionName( ) { } 

c. class object functionName( ) { } 

d. ClassName functionName ( ){ } 


Ans- ClassName functionName ( ){ }  


Que- Which is the correct syntax for defining a function which passes an object by reference? 

a. className& functionName ( ) 

b. className* functionName( ) 

c. className-> functionName( ) 

d. &className functionName() 


Ans- className& functionName ( )  


Que- If an object is declared inside the function then ____________________ outside the function 

a. It can be returned by reference 

b. It can't be returned by reference 

c. It can be returned by address 

d. It can't be returned at all 


Ans- It can't be returned by reference  


Que- How many independent objects can be returned at same time from a function? 

a. 1 

b. 2 

c. 3 

d. 4 


Ans- 1  


Que- Which error will be produced if a local object is returned by reference outside a function? 

a. Out of memory error 

b. Run time error 

c. Compile time error 

d. No error 


Ans- Compile time error  


Que- If object is passed by reference ____________________ 

a. Temporary object is created 

b. Temporary object is created inside the function 

c. Temporary object is created for few seconds 

d. Temporary object is not created 


Ans- Temporary object is not created  


Que- Which among the following is correct? 

a. Individual data members can't be returned 

b. Individual data members can be returned 

c. Individual member functions can be returned from another function 

d. Individual data members can only be passed by reference 


Ans- Individual data members can be returned  


Que- Can we return an array of objects? 

a. Yes, always 

b. Ye, only if objects are having same values 

c. No, because objects contain many other values 

d. No, because objects are single entity 


Ans- Yes, always  


Que- Which among the following is true? 

a. Two objects can point to the same memory location 

b. Two objects can never point to the same memory location 

c. Objects not allowed to point at a location already occupied 

d. Objects can't point to any address 


Ans- Two objects can point to the same memory location  


Que- If an object is being returned by value then __________________________ 

a. Its member values are made constant 

b. Its member values have to be copied individually 

c. Its member values are not used 

d. Its member values are copied using copy constructor 


Ans- Its member values are copied using copy constructor  


Que- Why temporary object is not created in return by reference? 

a. Because compiler can't create temporary objects 

b. Because the temporary object is created within the function 

c. Because return by reference just make the objects points to values memory location 

d. Because return by reference just make the object point to null 


Ans- Because return by reference just make the objects points to values memory location  


Que- When value of an object is assigned to another object, ___________________ 

a. It becomes invalid statement 

b. Its values gets copied into another object 

c. Its values gets address of the existing values 

d. The compiler doesn't execute that statement 


Ans- Its values gets copied into another object  


Que- If an object is created and another object is assigned to it, then ________________ 

a. Copy constructor is called to copy the values 

b. Object is copied directly to the object 

c. Reference to another object is created 

d. The new object is initialized to null values 


Ans- Reference to another object is created  


Que- How the argument passed to a function get initialized? 

a. Assigned using copy constructor at time of passing 

b. Copied directly 

c. Uses addresses always 

d. Doesn't get initialized 


Ans- Assigned using copy constructor at time of passing  


Que- If programmer doesn't define any copy assignment operator then ____________________ 

a. Compiler gives an error 

b. Program fails at run time 

c. Compiler gives an implicit definition 

d. Compiler can't copy the member values 


Ans- Compiler gives an implicit definition  


Que- In copy constructor definition, if non const values are accepted only ________ 

a. Only const objects will be accepted 

b. Only non - const objects are accepted 

c. Only const members will not get copied 

d. Compiler generates an error 


Ans- Only non - const objects are accepted  


Que- How many objects can be assigned to a single address? 

a. Only 1 

b. At most 7 

c. At most 3 

d. As many as required 


Ans- As many as required  


Que- Use of assignment operator ____________________ 

a. Changes its use, when used at declaration and in normal assignment 

b. Doesn't changes its use, whatever the syntax might be 

c. Assignment takes place in declaration and assignment syntax 

d. Doesn't work in normal syntax, but only with declaration 


Ans- Changes its use, when used at declaration and in normal assignment  


Que- If more than one object refer to the same address, any changes made 

a. Can be made visible to specific objects 

b. Will be specific to one object only 

c. From any object will be visible in all 

d. Doesn't changes the values of all objects 


Ans- From any object will be visible in all  


Que- How to make more than one object refer to the same object? 

a. Initialize it to null 

b. Initialize the object with another at declaration 

c. Use constructor to create new object 

d. Assign the address directly 


Ans- Initialize the object with another at declaration  


Que- We can assign ______________________ 

a. Value of one reference variable to another 

b. Value of any object to another 

c. Value of any type to any object 

d. Value of non-reference to another reference 


Ans- Value of one reference variable to another  


Que- Assigning reference to an object _________________ 

a. Will create another copy of the object 

b. Will create two different copies of the object 

c. Will not create any other copy of the object 

d. Will not refer to the object 


Ans- Will not create any other copy of the object  


Que- Which among the following is true? 

a. We can use direct assignment for any object 

b. We can use direct assignment only for different class objects 

c. We must not use direct assignment 

d. We can use direct assignment to same class objects 


Ans- We can use direct assignment to same class objects  


Que- Which language among the following doesn't allow pointers? 

a. C++ 

b. Java 

c. Pascal 

d. C 


Ans- Java  


Que- Which is correct syntax for declaring pointer to object? 

a. className* objectName; 

b. className objectName; 

c. *className objectName; 

d. className objectName(); 


Ans- className* objectName;  


Que- Which operator should be used to access the members of the class using object pointer? 

a. Dot operator 

b. Colon to the member 

c. Scope resolution operator 

d. Arrow operator 


Ans- Arrow operator  


Que- How does compiler decide the intended object to be used, if more than one object are used? 

a. Using object name 

b. Using an integer pointer 

c. Using this pointer 

d. Using void pointer 


Ans- Using this pointer  


Que- If pointer to an object is declared, ___________ 

a. It can store any type of address 

b. It can store only void addresses 

c. It can only store address of integer type 

d. It can only store object address of class type specified 


Ans- It can only store object address of class type specified  


Que- What is the size of object pointer? 

a. Equal to size of any usual pointer 

b. Equal to size of sum of all the members of object 

c. Equal to size of maximum sized member of object 

d. Equal to size of void 


Ans- Equal to size of any usual pointer  


Que- A pointer _________________ 

a. Can point to only one object at a time 

b. Can point to more than one objects at a time 

c. Can point to only 2 objects at a time 

d. Can point to whole class objects at a time 


Ans- Can point to only one object at a time  


Que- Pointer to a base class can be initialized with the address of derived class, because of _________ 

a. derived-to-base implicit conversion for pointers 

b. base-to-derived implicit conversion for pointers 

c. base-to-base implicit conversion for pointers 

d. derived-to-derived implicit conversion for pointers 


Ans- derived-to-base implicit conversion for pointers  


Que- Can pointers to object access the private members of the class? 

a. Yes, always 

b. Yes, only if it is only pointer to object 

c. No, because objects can be referenced from another objects too 

d. No, never 


Ans- No, never  


Que- Is name of an array of objects is also a pointer to object? 

a. Yes, always 

b. Yes, in few cases 

c. No, because it represents more than one object 

d. No, never 


Ans- Yes, always  


Que- Which among the following is true? 

a. The pointer to object can hold address only 

b. The pointer can hold value of any type 

c. The pointer can hold only void reference 

d. The pointer can't hold any value 


Ans- The pointer to object can hold address only  


Que- Which is the correct syntax to call a member function using pointer? 

a. pointer->function() 

b. pointer.function() 

c. pointer::function() 

d. pointer:function() 


Ans- pointer->function()  


Que- If pointer to an object is created and the object gets deleted without using the pointer: 

a. It becomes void pointer 

b. It becomes dangling pointer 

c. It becomes null pointer 

d. It becomes zero pointer 


Ans- It becomes dangling pointer  


Que- How can the address stored in the pointer be retrieved? 

a. Using * symbol 

b. Using $ symbol 

c. Using & symbol 

d. Using @ symbol 


Ans- Using & symbol  


Que- What should be done to prevent changes that may be made to the values pointed by the pointer? 

a. Usual pointer can't change the values pointed 

b. Pointer should be made virtual 

c. Pointer should be made anonymous 

d. Pointer should be made const 


Ans- Pointer should be made const  


Que- Which is the pointer which denotes the object calling the member function? 

a. Variable pointer 

b. This pointer 

c. Null pointer 

d. Zero pointer 


Ans- This pointer  


Que- Which among the following is true? 

a. this pointer is passed implicitly when member functions are called 

b. this pointer is passed explicitly when member functions are called 

c. this pointer is passed with help of pointer member functions are called 

d. this pointer is passed with help of void pointer member functions are called 


Ans- this pointer is passed implicitly when member functions are called  


Que- The this pointer is accessible __________________ 

a. Within all the member functions of the class 

b. Only within functions returning void 

c. Only within non-static functions 

d. Within the member functions with zero arguments 


Ans- Only within non-static functions  


Que- An object's this pointer _____________________ 

a. Isn't part of class 

b. Isn't part of program 

c. Isn't part of compiler 

d. Isn't part of object itself 


Ans- Isn't part of object itself  


Que- The result of sizeof() function __________________ 

a. Includes space reserved for this pointer 

b. Includes space taken up by the address pointer by this pointer 

c. Doesn't include the space taken by this pointer 

d. Doesn't include space for any data member 


Ans- Doesn't include the space taken by this pointer  


Que- Whenever non-static member functions are called _______________ 

a. Address of the object is passed implicitly as an argument 

b. Address of the object is passed explicitly as an argument 

c. Address is specified globally so that the address is not used again 

d. Address is specified as return type of the function 


Ans- Address of the object is passed implicitly as an argument  


Que- Which is the correct interpretation of the member function call from an object, object.function(parameter); 

a. object.function(&this, parameter) 

b. object(&function,parameter) 

c. function(&object,¶meter) 

d. function(&object,parameter) 


Ans- function(&object,parameter)  


Que- The address of the object _________________ 

a. Can't be accessed from inside the function 

b. Can't be accessed in the program 

c. Is available inside the member function using this pointer 

d. Can be accessed using the object name inside the member function 


Ans- Is available inside the member function using this pointer  


Que- Which among the following is true? 

a. This pointer can be used to guard against any kind of reference 

b. This pointer can be used to guard against self-reference 

c. This pointer can be used to guard from other pointers 

d. This pointer can be used to guard from parameter referencing 


Ans- This pointer can be used to guard against self-reference  


Que- Which syntax doesn't execute/is false when executed? 

a. if(&object != this) 

b. if(&function !=object) 

c. this.if(!this) 

d. this.function(!this) 


Ans- if(&object != this)  


Que- The this pointers _____________________ 

a. Are modifiable 

b. Can be assigned any value 

c. Are made variables 

d. Are non-modifiable 


Ans- Are non-modifiable  


Que- Earlier implementations of C++ ___________________ 

a. Never allowed assignment to this pointer 

b. Allowed no assignment to this pointer 

c. Allowed assignments to this pointer 

d. Never allowed assignment to any pointer 


Ans- Allowed assignments to this pointer  


Que- This pointer can be used directly to ___________ 

a. To manipulate self-referential data structures 

b. To manipulate any reference to pointers to member functions 

c. To manipulate class references 

d. To manipulate and disable any use of pointers 


Ans- To manipulate self-referential data structures  


Que- Which among the following is/are type(s) of this pointer? 

a. const 

b. volatile 

c. const or volatile 

d. int 


Ans- const or volatile  


Que- Which is the correct syntax for declaring type of this in a member function? 

a. classType [cv-qualifier-list] *const this; 

b. classType const[cv-qualifier-list] *this; 

c. [cv-qualifier-list]*const classType this; 

d. [cv-qualifier-list] classType *const this; 


Ans- [cv-qualifier-list] classType *const this;  


Que- What are default arguments? 

a. Arguments which are not mandatory to be passed 

b. Arguments with default value that aren't mandatory to be passed 

c. Arguments which are not passed to functions 

d. Arguments which always take same data value 


Ans- Arguments with default value that aren't mandatory to be passed  


Que- Which is correct condition for the default arguments? 

a. Those must be declared as last arguments in argument list 

b. Those must be declared first in the argument list 

c. Those can be defined anywhere in the argument list 

d. Those are declared inside the function definition 


Ans- Those must be declared as last arguments in argument list  


Que- If a member function have to be made both zero argument and parameterized constructor, which among the following can be the best option? 

a. Two normal and one default argument 

b. At least one default argument 

c. Exactly one default argument 

d. Make all the arguments default 


Ans- Make all the arguments default  


Que- Which among the following function can be called without arguments? 

a. void add(int x, int y=0) 

b. void add(int=0) 

c. void add(int x=0, int y=0) 

d. void add(char  


Ans- void add(int x=0, int y=0)  


Que- If a function have all the default arguments but still some values are passed to the function then ______________ 

a. The function will use the values passed to it 

b. The function will use the default values as those are local 

c. The function can use any value whichever is higher 

d. The function will choose the minimum values 


Ans- The function will use the values passed to it  


Que- Which among the following is correct? 

a. void test(int x=0, int y, int z=0) 

b. void test(int x=0,int=0) 

c. void test(int x,int y=0) 

d. void test(int x='c',int y) 


Ans- void test(int x,int y=0)  


Que- What function will be called with the independent syntax �test(5,6,7);�? 

a. void test(int x, int y) 

b. void test(int x=0,int y,int z) 

c. int test(int x=0,y=0,z=0) 

d. void test(int x,int y, int z=0) 


Ans- void test(int x,int y, int z=0)  


Que- Which among the following is wrong call to the function void test(int x, int y=0, int z=0)? 

a. test(5,6,7); 

b. test(5); 

c. test(); 

d. test(5,6); 


Ans- test();  


Que- Default arguments are _________________________ 

a. Only allowed in the parameter list of the function declaration 

b. Only allowed in the return type of the function declaration 

c. Only allowed with the class name definition 

d. Only allowed with the integer type values 


Ans- Only allowed in the parameter list of the function declaration  


Que- Which among the following is false for default arguments? 

a. Those are not allowed with declaration of pointer to functions 

b. Those are not allowed with the reference to functions 

c. Those are not allowed with the typedef declarations 

d. Those are allowed with pointer and reference to function declaration 


Ans- Those are allowed with pointer and reference to function declaration  


Que- The non-template functions can be added with default arguments to already declared functions ____________________ 

a. If and only if the function is declared again in the same scope 

b. If and only if the function is declared only once in the same scope 

c. If and only if the function is declared in different scope 

d. If and only if the function is declared twice in the program 


Ans- If and only if the function is declared again in the same scope  


Que- The using declaration __________ 

a. Doesn't carry over the default values 

b. Carries over the known default arguments 

c. Carries over only the normal arguments 

d. Carries over only few default arguments 


Ans- Carries over the known default arguments  


Que- The names given to the default arguments are only looked up and ________________. And are bound during declaration. 

a. Checked for availability 

b. Checked for random access 

c. Checked for accessibility 

d. Checked for feasibility 


Ans- Checked for accessibility  


Que- The default argument get bound during declaration ________________ 

a. And are never executed 

b. And are executed simultaneously 

c. But are executed only if priority is given 

d. But are executed during function call 


Ans- But are executed during function call  


Que- The virtual function overrides ____________ 

a. Do not acquire base class declaration of default arguments 

b. Do acquire base class declaration of default arguments 

c. Do not link with the default arguments of base class 

d. Do link with the default argument but only of derived classes 


Ans- Do not acquire base class declaration of default arguments  


Que- Which among the following is true for constructors overloading? 

a. Constructors can't be overloaded 

b. Constructors can be overloaded using different signatures 

c. Constructors can be overloaded with same signatures 

d. Constructors can be overloaded with different return types 


Ans- Constructors can be overloaded using different signatures  


Que- If a constructors should be capable of creating objects without argument and with arguments, which is a good alternative for this purpose? 

a. Use zero argument constructor 

b. Use constructor with one parameter 

c. Use constructor with all default arguments 

d. Use default constructor 


Ans- Use constructor with all default arguments  


Que- Which among the following is true? 

a. The constructors overloading can be done by using different names 

b. The constructors overloading can be done by using different return types 

c. The constructors can be overloaded by using only one argument 

d. The constructors must have same name as that of class 


Ans- The constructors must have same name as that of class  


Que- Which among the following can be used in place of default constructor? 

a. constructorName(int x,int y=0) 

b. constructorName(int x=0,int y=0) 

c. constructorName(int x=0,int y) 

d. constructorName(int x,int y) 


Ans- constructorName(int x=0,int y=0)  


Que- Can a class have more than one function with all the default arguments? 

a. Yes, always 

b. Yes, if argument list is different 

c. No, because constructors overloading doesn't depend on argument list 

d. No, never 


Ans- No, never  


Que- Which is the correct syntax for using default arguments with the constructor? 

a. default constructorName(default int x=0) 

b. constructorName(default int x=0) 

c. constructorName(int x=0) 

d. constructorName() 


Ans- constructorName(int x=0)  


Que- How many parameters must be passed if only the following prototype is given to a constructor?Prototype: className(int x, int y, int z=0); 

a. 1 

b. 2 

c. 3 

d. Compile time error 


Ans- 2  


Que- If the constructors are overloaded by using the default arguments, which problem may arise? 

a. The constructors might have all the same arguments except the default arguments 

b. The constructors might have same return type 

c. The constructors might have same number of arguments 

d. The constructors can't be overloaded with respect to default arguments 


Ans- The constructors might have all the same arguments except the default arguments  


Que- Which among the following is true? 

a. More than one constructors with all default arguments is allowed 

b. More than one constructors with all default arguments can be defined outside the class 

c. More than one constructors can be used with same argument list 

d. More than one constructors with all default arguments can't exist in same class 


Ans- More than one constructors with all default arguments can't exist in same class  


Que- Which constructor among the following will be called if a call is made like className(5,'a');? 

a. className(int x=5,char c='a'); 

b. int className(int x, char c, char a); 

c. className(int x, char c, int y); 

d. char className(char c,int x); 


Ans- className(int x=5,char c='a');  


Que- If there is a constructor with all the default arguments and arguments are not passed then _________________ 

a. The default values given will not be used 

b. Then all the null values will be used 

c. Then all the default values given will be used 

d. Then compiler will produce an error 


Ans- Then all the default values given will be used  


Que- Which is the correct statement for default constructors? 

a. The constructors with all the default arguments 

b. The constructors with all the null and zero values 

c. The constructors which can't be defined by programmer 

d. The constructors with zero arguments 


Ans- The constructors with zero arguments  


Que- Which is a good alternative instead of having one zero argument constructor and one single argument constructor with default argument? 

a. No constructor defined 

b. One default value constructor 

c. Defining the default constructor 

d. Using one constructor with two arguments 


Ans- One default value constructor  


Que- What is upcasting? 

a. Casting subtype to supertype 

b. Casting super type to subtype 

c. Casting subtype to super type and vice versa 

d. Casting anytype to any other type 


Ans- Casting subtype to supertype  


Que- Which among the following is true for upcasting in inheritance? 

a. Downward to the inheritance tree 

b. Upward to the inheritance tree 

c. Either upward or downward 

d. Doesn't apply on inheritance 


Ans- Upward to the inheritance tree  


Que- Which among the following is safe? 

a. Upcasting 

b. Downcasting 

c. Both upcasting and downcasting 

d. If upcasting is safe then downcasting is not, and vice versa 


Ans- Upcasting  


Que- Which among the following is best situation to use upcasting? 

a. For general code dealing with only subtype 

b. For general code dealing with only supertype 

c. For general code dealing with both the supertype and subtype 

d. For writing a rigid code with respect to subtype 


Ans- For general code dealing with only supertype  


Que- Which property is shown most when upcasting is used? 

a. Code reusability 

b. Code efficiency 

c. Complex code simple syntax 

d. Encapsulation 


Ans- Complex code simple syntax  


Que- If multiple inheritance is implemented, which upcasting will be correct? 

a. Upcast to first base class listed in inheritance 

b. Upcast to send base class listed in inheritance 

c. Upcast to any base class 

d. Upcast is not possible 


Ans- Upcast to any base class  


Que- If class C inherits class B and class B inherits class A ________________ 

a. Class C object can be upcasted to object of class B only 

b. Class C object can be upcasted to object of class A only 

c. Class C object can be upcasted to object of either class A or B 

d. Class C object can't be upcasted 


Ans- Class C object can be upcasted to object of either class A or B  


Que- Upcasting is _____________________ without an explicit type cast. 

a. Always allowed for public inheritance 

b. Always allowed for protected inheritance 

c. Always allowed for private inheritance 

d. Not allowed 


Ans- Always allowed for public inheritance  


Que- Which concept is needed because of implicit type casting use? 

a. Static binding 

b. Dynamic binding 

c. Compile time binding 

d. Source code binding 


Ans- Dynamic binding  


Que- When are the pointer types known for upcasting the objects? 

a. Compile time 

b. Runtime 

c. Source code build time 

d. Doesn't apply to pointer types 


Ans- Compile time  


Que- When are the object type known for upcasting the objects? 

a. Compile time 

b. Runtime 

c. Source code build time 

d. Doesn't apply to objects directly 


Ans- Runtime  


Que- If two classes are defined "Parent" and "Child" then which is the correct type upcast syntax in C++? 

a. Parent *p=child; 

b. Parent *p=*child; 

c. Parent *p=&child; 

d. Parent *p=Child(); 


Ans- Parent *p=&child;  


Que- Which among the following is true? 

a. Upcasting is possible only for single level inheritance 

b. Upcasting is possible only for multilevel inheritance 

c. Upcasting is possible only for multiple inheritance 

d. Upcasting is possible for any type of inheritance 


Ans- Upcasting is possible for any type of inheritance  


Que- What is downcasting? 

a. Casting subtype to supertype 

b. Casting supertype to subtype 

c. Casting subtype to supertype and vice versa 

d. Casting anytype to any other type 


Ans- Casting supertype to subtype  


Que- Which among the following is a mandatory condition for downcasting? 

a. It must not be done explicitly 

b. It must be done implicitly 

c. It must be done explicitly 

d. It can't be done explicitly 


Ans- It must be done explicitly  


Que- Downcasting is _______________________ 

a. Always safe 

b. Never safe 

c. Safe sometimes 

d. Safe, depending on code 


Ans- Never safe  


Que- Downcasting ____________________ 

a. Can result in unexpected results 

b. Can't result in unexpected result 

c. Can result only in out of memory error 

d. Can't result in any error 


Ans- Can result in unexpected results  


Que- What should be used for safe downcast? 

a. Static cast 

b. Dynamic cast 

c. Manual cast 

d. Implicit cast 


Ans- Dynamic cast  


Que- What does dynamic_cast return after successful type casting? 

a. Address of object which is converted 

b. Address of object that is used for conversion 

c. Address of object that is mentioned in the syntax 

d. Doesn't return any address 


Ans- Address of object which is converted  


Que- If dynamic_cast fails, which value is returned? 

a. void 

b. null 

c. void pointer 

d. null pointer 


Ans- null pointer  


Que- Which is the proper syntax of dynamic_cast? 

a. dynamic_cast(object) 

b. dynamic_cast new (object) 

c. dynamic_cast(object) 

d. dynamic_cast(object) 


Ans- dynamic_cast(object)  


Que- Which is the exception handler for the exceptions of downcasting? 

a. CastException 

b. ClassCastingExeption 

c. ClassCasting 

d. ClassCastException 


Ans- ClassCastException  


Que- How to prevent the ClassCastExceptions? 

a. By using instanceof 

b. By using is-a check 

c. By using arrow operator with check function 

d. By checking type of conversion 


Ans- By using instanceof  


Que- Which way the downcasting is possible with respect to inheritance? 

a. Upward the inheritance order 

b. Downward the inheritance order 

c. Either upward or downward the inheritance order 

d. Order of inheritance doesn't matter 


Ans- Downward the inheritance order  


Que- What happens when downcasting is done but not explicitly defined in syntax? 

a. Compile time error 

b. Runtime error 

c. Code write time error 

d. Conversion error 

Ans- Compile time error  

Previous Post Next Post