Object Oriented Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Object Oriented Programming MCQ (Multiple Choice Questions)

 Que- Which among the following is true for virtual functions? 

a. Prototype must be different in base and derived class 

b. Prototype must be same in base class and derived class 

c. Prototype must be given only in base class 

d. Prototype must have different signature in base and derived class 


Ans- Prototype must be same in base class and derived class  


Que- The virtual functions must be declared and defined in _____________ class and overridden in ___________ class. 

a. Base, base 

b. Derived, derived 

c. Derived, base 

d. Base, derived 


Ans- Base, derived  


Que- It is __________ to redefine the virtual function in derived class? 

a. Necessary 

b. Not necessary 

c. Not acceptable 

d. Good practice 


Ans- Not necessary  


Que- Which among the following is true? 

a. A class may have virtual destructor but not virtual constructor 

b. A class may have virtual constructor but not virtual destructor 

c. A class may have virtual constructor and virtual constructor 

d. A class may have either virtual destructor or virtual constructor 


Ans- A class may have virtual destructor but not virtual constructor  


Que- If virtual function of base class is redefined in derived class then, ________________________ 

a. It must be declared virtual in derived class also 

b. It may or may not be declared virtual in derived class 

c. It can must not be declared virtual in derived class 

d. It must be declared normally in derived class 


Ans- It may or may not be declared virtual in derived class  


Que- Which among the following best defines the abstract methods? 

a. Functions declared and defined in base class 

b. Functions only declared in base class 

c. Function which may or may not be defined in base class 

d. Function which must be declared in derived class 


Ans- Functions only declared in base class  


Que- Which among the following is true? 

a. The abstract functions must be only declared in derived classes 

b. The abstract functions must not be defined in derived classes 

c. The abstract functions must be defined in base and derived class 

d. The abstract functions must be defined either in base or derived class 


Ans- The abstract functions must be only declared in derived classes  


Que- How are abstract functions different from the abstract functions? 

a. Abstract must not be defined in base class whereas virtual function can be defined 

b. Either of those must be defined in base class 

c. Different according to definition 

d. Abstract functions are faster 


Ans- Abstract must not be defined in base class whereas virtual function can be defined  


Que- Which among the following is correct? 

a. Abstract functions should not be defined in all the derived classes 

b. Abstract functions should be defined only in one derived class 

c. Abstract functions must be defined in base class 

d. Abstract functions must be defined in all the derived classes 


Ans- Abstract functions must be defined in all the derived classes  


Que- It is _________________________ to define the abstract functions. 

a. Mandatory for all the classes in program 

b. Necessary for all the base classes 

c. Necessary for all the derived classes 

d. Not mandatory for all the derived classes 


Ans- Necessary for all the derived classes  


Que- The abstract function definitions in derived classes is enforced at _________ 

a. Runtime 

b. Compile time 

c. Writing code time 

d. Interpreting time 


Ans- Compile time  


Que- What is this feature of enforcing definitions of abstract function at compile time called? 

a. Static polymorphism 

b. Polymorphism 

c. Dynamic polymorphism 

d. Static or dynamic according to need 


Ans- Dynamic polymorphism  


Que- What is the syntax for using abstract method? 

a. <access-modifier>abstract<return-type>method_name (parameter) 

b. abs<return-type>method name (parameter) 

c. <access-modifier>abstract return-type method name (parameter) 

d. <access-modifier>abstract <returning> method name (parameter) 


Ans- <access-modifier>abstract<return-type>method_name (parameter)  


Que- If a function declared as abstract in base class doesn't have to be defined in derived class then ______ 

a. Derived class must define the function anyhow 

b. Derived class should be made abstract class 

c. Derived class should not derive from that base class 

d. Derived class should not use that function 


Ans- Derived class should be made abstract class  


Que- Which among the following is true? 

a. Abstract methods can be static 

b. Abstract methods can be defined in derived class 

c. Abstract methods must not be static 

d. Abstract methods can be made static in derived class 


Ans- Abstract methods must not be static  


Que- Which among the following is correct for abstract methods? 

a. It must have different prototype in the derived class 

b. It must have same prototype in both base and derived class 

c. It must have different signature in derived class 

d. It must have same return type only 


Ans- It must have same prototype in both base and derived class  


Que- If a class have all the abstract methods the class will be known as ___________ 

a. Abstract class 

b. Anonymous class 

c. Base class 

d. Derived class 


Ans- Abstract class  


Que- The abstract methods can never be ___________ in a base class. 

a. Private 

b. Protected 

c. Public 

d. Default 


Ans- Private  


Que- The abstract method definition can be made ___________ in derived class. 

a. Private 

b. Protected 

c. Public 

d. Private, public, or protected 


Ans- Private, public, or protected  


Que- How many types of member functions are possible in general? 

a. 2 

b. 3 

c. 4 

d. 5 


Ans- 5  


Que- Simple member functions are ______________________ 

a. Ones defined simply without any type 

b. Ones defined with keyword simple 

c. Ones that are implicitly provided 

d. Ones which are defined in all the classes 


Ans- Ones defined simply without any type  


Que- What are static member functions? 

a. Functions which use only static data member but can't be accessed directly 

b. Functions which uses static and other data members 

c. Functions which can be access outside the class with the data members 

d. Functions using only static data and can be accessed directly in main() function 


Ans- Functions using only static data and can be accessed directly in main() function  


Que- How can static member function can be accessed directly in main() function? 

a. Dot operator 

b. Colon 

c. Scope resolution operator 

d. Arrow operator 


Ans- Scope resolution operator  


Que- Correct syntax to access the static member functions from the main() function is: 

a. classObject::functionName(); 

b. className::functionName(); 

c. className:classObject:functionName(); 

d. className.classObject:functionName(); 


Ans- className::functionName();  


Que- What are const member functions? 

a. Functions in which none of the data members can be changed in a program 

b. Functions in which only static members can be changed 

c. Functions which treat all the data members as constant and doesn't allow changes 

d. Functions which can change only the static members 


Ans- Functions which treat all the data members as constant and doesn't allow changes  


Que- Which among the following best describes the inline member functions? 

a. Functions defined inside the class only 

b. Functions with keyword inline only 

c. Functions defined outside the class 

d. Functions defined inside the class or with the keyword inline 


Ans- Functions defined inside the class or with the keyword inline  


Que- What are friend member functions (C++)? 

a. Member function which can access all the members of a class 

b. Member function which can modify any data of a class 

c. Member function which doesn't have access to private members 

d. Non-member functions which have access to all the members (including private) of a class 


Ans- Non-member functions which have access to all the members (including private) of a class  


Que- What is the syntax of a const member function? 

a. void fun() const {} 

b. void fun() constant {} 

c. void const fun() {} 

d. const void fun(){} 


Ans- void fun() const {}  


Que- Which keyword is used to make a nonmember function as friend function of a class? 

a. friendly 

b. new 

c. friend 

d. connect 


Ans- friend  


Que- Member functions _____________________ 

a. Must be defined inside class body 

b. Can be defined inside class body or outside 

c. Must be defined outside the class body 

d. Can be defined in another class 


Ans- Must be defined outside the class body  


Que- Which among the following is true? 

a. Member functions can never be private 

b. Member functions can never be protected 

c. Member functions can never be public 

d. Member functions can be defined in any access specifier 


Ans- Member functions can be defined in any access specifier  


Que- Which keyword is used to define the static member functions? 

a. static 

b. stop 

c. open 

d. state 


Ans- static  


Que- Which keyword is used to define the inline member function? 

a. No keyword required 

b. inline 

c. inlined 

d. line 


Ans- inline  


Que- Which among the following are valid ways of overloading the operators? 

a. Only using friend function 

b. Only using member function 

c. Either member functions or friend functions can be used 

d. Operators can't be overloaded 


Ans- Either member functions or friend functions can be used  


Que- Which among the following is mandatory condition for operators overloading? 

a. Overloaded operator must be member function of the left operand 

b. Overloaded operator must be member function of the right operand 

c. Overloaded operator must be member function of either left or right operand 

d. Overloaded operator must not be dependent on the operands 


Ans- Overloaded operator must be member function of the left operand  


Que- When the operator to be overloaded becomes the left operand member then ______________ 

a. The right operand acts as implicit object represented by *this 

b. The left operand acts as implicit object represented by *this 

c. Either right or left operand acts as implicit object represented by *this 

d. *this pointer is not applicable in that member function 


Ans- The left operand acts as implicit object represented by *this  


Que- If the left operand is pointed by *this pointer, what happens to other operands? 

a. Other operands are passed as function return type 

b. Other operands are passed to compiler implicitly 

c. Other operands must be passed using another member function 

d. Other operands are passed as function arguments 


Ans- Other operands are passed as function arguments  


Que- If a friend overloaded operator have to be changed to member overloaded operator, which operator should be used with the class name? 

a. Scope resolution operator 

b. Colon 

c. Arrow operator 

d. Dot operator 


Ans- Scope resolution operator  


Que- What is the syntax to overload an operator? 

a. className::operator(parameters) 

b. className:operator(parameters) 

c. className.operator(paramteres) 

d. className->operator(parameters) 


Ans- className::operator(parameters)  


Que- Why the left parameter is removed from parameter list? 

a. Because it is of no use 

b. Because it is never used in definitions 

c. Because it becomes parameter pointed by *this 

d. Because it can't be referred by *this pointer 


Ans- Because it becomes parameter pointed by *this  


Que- Which object's members can be called directly while overloading operator function is used (In function definition)? 

a. Left operand members 

b. Right operand members 

c. All operand members 

d. None of the members 


Ans- Left operand members  


Que- If left operand member is specified directly in the function definition, which is the correct implicit conversion of that syntax? 

a. *this className 

b. *this parameterObject 

c. *this returnedObject 

d. *this object 


Ans- *this object  


Que- When the friend operator overloading is converted into member operator overloading _______________ 

a. Two parameters of friend function remains same parameters in member operator overloading 

b. Two parameters of friend function becomes only one parameter of member function 

c. Two parameters of friend function are removed while using member function 

d. Two parameters of friend function are made 4 in member operator overloading 


Ans- Two parameters of friend function becomes only one parameter of member function  


Que- Where in the parameter list is the implicit *this is added? 

a. Right most parameter 

b. Anywhere in parameter list 

c. Left most parameter 

d. Not added to parameter list 


Ans- Left most parameter  


Que- Which operator among the following can be overloading using only member function? 

a. Assignment operator 

b. Addition operator 

c. Subtraction operator 

d. Multiplication and division operator 


Ans- Assignment operator  


Que- Which operator among the following can be overloaded using both friend function and member function? 

a. Assignment operator 

b. Subscript 

c. Member selection (arrow operator) 

d. Modulus operator 


Ans- Modulus operator  


Que- Which operator among the following must be overloaded using the friend function? 

a. << operator only 

b. >> operator only 

c. Both << and >> operators 

d. It's not mandatory to use friend function in any case 


Ans- Both << and >> operators  


Que- What does memory allocation for objects mean? 

a. Actual creation and memory allocation for object members 

b. Creation of member functions 

c. Creation of data members for a class 

d. Actual creation and data declaration for object members 


Ans- Actual creation and memory allocation for object members  


Que- Where is the memory allocated for the objects? 

a. HDD 

b. Cache 

c. RAM 

d. ROM 


Ans- RAM  


Que- When is the memory allocated for an object? 

a. At declaration of object 

b. At compile time 

c. When object constructor is called 

d. When object is initialized to another object 


Ans- When object constructor is called  


Que- Using new is type safe as _______________________ 

a. It require to be specified with type of data 

b. It doesn't require to be specified with type of data 

c. It requires the name of data 

d. It allocated memory for the data 


Ans- It doesn't require to be specified with type of data  


Que- Which of the following function can be used for dynamic memory allocation of objects? 

a. malloc() 

b. calloc() 

c. create() 

d. both malloc() and calloc() 


Ans- both malloc() and calloc()  


Que- How much memory will be allocated for an object of class given below?class Test{int mark1;int mark2;float avg;char name[10];}; 

a. 22 Bytes 

b. 24 Bytes 

c. 20 Bytes 

d. 18 Bytes 


Ans- 22 Bytes  


Que- Which keyword among the following can be used to declare an array of objects in java? 

a. new 

b. create 

c. allocate 

d. arr 


Ans- new  


Que- When is the memory allocated for an object gets free? 

a. At termination of program 

b. When object goes out of scope 

c. When main function ends 

d. When system restarts 


Ans- When object goes out of scope  


Que- Which among the following keyword can be used to free the allocated memory for an object? 

a. delete 

b. free 

c. either delete or free 

d. only delete 


Ans- either delete or free  


Que- Which function is called whenever an object goes out of scope? 

a. Destructor function 

b. Constructor function 

c. Delete function 

d. Free function 


Ans- Destructor function  


Que- Which operator can be used to check the size of an object? 

a. sizeof(objectName) 

b. size(objectName) 

c. sizeofobject(objectName) 

d. sizedobject(objectName) 


Ans- sizeof(objectName)  


Que- The memory allocated for an object ____________________ 

a. Can be only dynamic 

b. Can be only static 

c. Can be static or dynamic 

d. Can't be done using dynamic functions 


Ans- Can be static or dynamic  


Que- If an object is declared in a user defined function __________________ 

a. Its memory is allocated in stack 

b. Its memory is allocated in heap 

c. Its memory is allocated in HDD 

d. Its memory is allocated in cache 


Ans- Its memory is allocated in stack  


Que- In java, ____________________ takes care of managing memory for objects dynamically. 

a. Free collector 

b. Dust collector 

c. Memory manager 

d. Garbage collector 


Ans- Garbage collector  


Que- Which operator can be used to free the memory allocated for an object in C++? 

a. Free() 

b. delete 

c. Unallocate 

d. Collect 


Ans- delete  


Que- Which among the following best describes member function overriding? 

a. Member functions having same name in base and derived classes 

b. Member functions having same name in base class only 

c. Member functions having same name in derived class only 

d. Member functions having same name and different signature inside main function 


Ans- Member functions having same name in base and derived classes  


Que- Which among the following is true? 

a. Inheritance must not be using when overriding is used 

b. Overriding can be implemented without using inheritance 

c. Inheritance must be done, to use overriding are overridden 

d. Inheritance is mandatory only if more than one functions 


Ans- Inheritance must be done, to use overriding are overridden  


Previous Post Next Post