R4RIN
Articles
Java 8
MCQS
OOPS MCQ Quiz Hub
OOPS Mcq Question Set 4
Choose a topic to test your knowledge and improve your OOPS skills
1. Which is the correct condition for function overriding?
The declaration must not be same in base and derived class
The declaration must be exactly the same in base and derived class
The declaration should have at least 1 same argument in declaration of base and derived class
The declaration should have at least 1 different argument in declaration of base and derived class
2. Exactly same declaration in base and derived class includes________
Only same name
Only same return type and name
Only same return type and argument list
All the same return type, name and parameter list
3. How to access the overridden method of base class from the derived class?
Using arrow operator
Using dot operator
Using scope resolution operator
Can’t be accessed once overridden
4. The functions to be overridden ____
Must be private in base class
Must not be private base class
Must be private in both derived and base class
Must not be private in both derived and base class
5. Which language doesn’t support the method overriding implicitly?
C++
C#
Java
SmallTalk
6. In C# ________
Non – virtual or static methods can’t be overridden
Non – virtual and static methods only can be overridden
Overriding is not allowed
Overriding must be implemented using C++ code only
7. In Delphi _______
Method overriding is done implicitly
Method overriding is not supported
Method overriding is done with directive override
Method overriding is done with the directive virtually
8. What should be used to call the base class method from the derived class if function overriding is used in Java?
Keyword super
Scope resolution
Dot operator
Function name in parenthesis
9. In Kotlin, the function to be overridden must be ______
Private
Open
Closed
Abstract
10. Abstract functions of a base class ______
Are overridden by the definition in same class
Are overridden by the definition in parent class
Are not overridden generally
Are overridden by the definition in derived class
11. If virtual functions are defined in the base class then ________
It is not necessary for derived classes to override those functions
It is necessary for derived classes to override those functions
Those functions can never be derived
Those functions must be overridden by all the derived classes
12. Which is private member functions access scope?
Member functions which can only be used within the class
Member functions which can used outside the class
Member functions which are accessible in derived class
Member functions which can’t be accessed inside the class
13. Which among the following is true?
The private members can’t be accessed by public members of the class
The private members can be accessed by public members of the class
The private members can be accessed only by the private members of the class
The private members can’t be accessed by the protected members of the class
14. Which member can never be accessed by inherited classes?
Private member function
Public member function
Protected member function
All can be accessed
15. Which syntax among the following shows that a member is private in a class?
private: functionName(parameters)
private(functionName(parameters))
private functionName(parameters)
private::functionName(parameters)
16. If private member functions are to be declared in C++ then ________
private: <all private members>
private <member name>
private(private member list)
private :- <private members>
17. In java, which rule must be followed?
Keyword private preceding list of private member’s
Keyword private with a colon before list of private member’s
Keyword private with arrow before each private member
Keyword private preceding each private member
18. How many private member functions are allowed in a class?
Only 1
Only 7
Only 255
As many as required
19. How to access a private member function of a class?
Using object of class
Using object pointer
Using address of member function
Using class address
20. Private member functions _______
Can’t be called from enclosing class
Can be accessed from enclosing class
Can be accessed only if nested class is private
Can be accessed only if nested class is public
21. Which function among the following can’t be accessed outside the class in java in same package?
public void show()
void show()
protected show()
static void show()
22. If private members are to be called outside the class, which is a good alternative?
Call a public member function which calls private function
Call a private member function which calls private function
Call a protected member function which calls private function
Not possible
23. A private function of a derived class can be accessed by the parent class.
True
False
all of the above
None of the mentioned
24. Which error will be produced if private members are accessed?
Can’t access private message
Code unreachable
Core dumped
Bad code
25. Can main() function be made private?
Yes, always
Yes, if program doesn’t contain any classes
No, because main function is user defined
No, never
26. If a function in java is declared private then it ______
Can’t access the standard output
Can access the standard output
Can’t access any output stream
Can access only the output streams
27. What does memory allocation for objects mean?
Actual creation and memory allocation for object members
Creation of member functions
Creation of data members for a class
Actual creation and data declaration for object members
28. When is the memory allocated for an object?
At declaration of object
At compile time
When object constructor is called
When object is initialized to another object
29. Using new is type safe as ______
t require to be specified with type of data
It doesn’t require to be specified with type of data
It requires the name of data
It allocated memory for the data
30. Which of the following function can be used for dynamic memory allocation of objects?
malloc()
calloc()
create()
both malloc() and calloc()
31. How much memory will be allocated for an object of class given below? class Test{ int mark1; int mark2; float avg; char name[10]; };
22 Bytes
24 Bytes
20 Bytes
18 Bytes
32. When is the memory allocated for an object gets free?
At termination of program
When object goes out of scope
When main function ends
When system restarts
33. Which among the following keyword can be used to free the allocated memory for an object?
delete
free
either delete or free
only delete
34. Which function is called whenever an object goes out of scope?
Destructor function
Constructor function
Delete function
Free function
35. Which operator can be used to check the size of an object?
sizeof(objectName)
size(objectName)
sizeofobject(objectName)
sizedobject(objectName)
36. The memory allocated for an object ________
Can be only dynamic
Can be only static
Can be static or dynamic
Can’t be done using dynamic functions
37. If an object is declared in a user defined function ___________
Its memory is allocated in stack
Its memory is allocated in heap
Its memory is allocated in HDD
Its memory is allocated in cache
38. In java ________ takes care of managing memory for objects dynamically.
Free collector
Dust collector
Memory manager
Garbage collector
39. Which among the following are valid ways of overloading the operators?
Only using friend function
Only using member function
Either member functions or friend functions can be used
Operators can’t be overloaded
40. Which among the following is mandatory condition for operators overloading?
Overloaded operator must be member function of the left operand
Overloaded operator must be member function of the right operand
Overloaded operator must be member function of either left or right operand
Overloaded operator must not be dependent on the operands
41. When the operator to be overloaded becomes the left operand member then ______
The right operand acts as implicit object represented by *this
The left operand acts as implicit object represented by *this
Either right or left operand acts as implicit object represented by *this
*this pointer is not applicable in that member function
42. If the left operand is pointed by *this pointer, what happens to other operands?
Other operands are passed as function return type
Other operands are passed to compiler implicitly
Other operands must be passed using another member function
Other operands are passed as function arguments
43. If a friend overloaded operator have to be changed to member overloaded operator, which operator should be used with the class name?
Scope resolution operator
Colon
Arrow operator
Dot operator
44. What is the syntax to overload an operator?
className::operator<operatorSymbol>(parameters)
className:operator<operatorSymbol>(parameters)
className.operator<operatorSymbol>(paramteres)
className->operator<operatorSymbol>(parameters)
45. Why the left parameter is removed from parameter list?
Because it is of no use
Because it is never used in definitions
Because it becomes parameter pointed by *this
Because it can’t be referred by *this pointer
46. Which object’s members can be called directly while overloading operator function is used (In function definition)?
Left operand members
Right operand members
All operand members
None of the members
47. If left operand member is specified directly in the function definition, which is the correct implicit conversion of that syntax?
*this className
*this parameterObject
*this returnedObject
*this object
48. When the friend operator overloading is converted into member operator overloading ____
Two parameters of friend function remains same parameters in member operator overloading
Two parameters of friend function becomes only one parameter of member function
Two parameters of friend function are removed while using member function
Two parameters of friend function are made 4 in member operator overloading
49. Where in the parameter list is the implicit *this is added?
Right most parameter
Anywhere in parameter list
Left most parameter
Not added to parameter list
50. Which operator among the following can be overloading using only member function?
Assignment operator
Addition operator
Subtraction operator
Multiplication and division operator
Submit