OOPS/OOPS Mcq Question Set 4 Sample Test,Sample questions

Question:
 Abstract functions of a base class ______

1.Are overridden by the definition in same class

2.Are overridden by the definition in parent class

3.Are not overridden generally

4.Are overridden by the definition in derived class


Question:
 In Delphi _______

1.Method overriding is done implicitly

2. Method overriding is not supported

3.Method overriding is done with directive override

4.Method overriding is done with the directive virtually


Question:
 Private member functions _______

1.Can’t be called from enclosing class

2.Can be accessed from enclosing class

3. Can be accessed only if nested class is private

4. Can be accessed only if nested class is public


Question:
 Which object’s members can be called directly while overloading operator function is used (In function definition)?

1.Left operand members

2.Right operand members

3.All operand members

4. None of the members


Question:
A private function of a derived class can be accessed by the parent class.

1.True

2.False

3.all of the above

4.None of the mentioned


Question:
Can main() function be made private?

1.Yes, always

2. Yes, if program doesn’t contain any classes

3.No, because main function is user defined

4.No, never


Question:
Exactly same declaration in base and derived class includes________

1. Only same name

2. Only same return type and name

3.Only same return type and argument list

4. All the same return type, name and parameter list


Question:
How many private member functions are allowed in a class?

1.Only 1

2. Only 7

3.Only 255

4. As many as required


Question:
How much memory will be allocated for an object of class given below?

class Test{
int mark1;
int mark2;
float avg;
char name[10];
};

1.22 Bytes

2.24 Bytes

3.20 Bytes

4.18 Bytes


Question:
How to access a private member function of a class?

1.Using object of class

2.Using object pointer

3. Using address of member function

4.Using class address


Question:
How to access the overridden method of base class from the derived class?

1.Using arrow operator

2.Using dot operator

3.Using scope resolution operator

4.Can’t be accessed once overridden


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

1.Scope resolution operator

2. Colon

3.Arrow operator

4.Dot operator


Question:
If a function in java is declared private then it ______

1.Can’t access the standard output

2.Can access the standard output

3.Can’t access any output stream

4. Can access only the output streams


Question:
If an object is declared in a user defined function ___________

1.Its memory is allocated in stack

2.Its memory is allocated in heap

3. Its memory is allocated in HDD

4.Its memory is allocated in cache


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

1.*this className

2.*this parameterObject

3.*this returnedObject

4. *this object


Question:
If private member functions are to be declared in C++ then ________

1.private: <all private members>

2.private <member name>

3.private(private member list)

4.private :- <private members>


Question:
If private members are to be called outside the class, which is a good alternative?

1.Call a public member function which calls private function

2.Call a private member function which calls private function

3.Call a protected member function which calls private function

4.Not possible


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

1.Other operands are passed as function return type

2.Other operands are passed to compiler implicitly

3.Other operands must be passed using another member function

4.Other operands are passed as function arguments


Question:
If virtual functions are defined in the base class then ________

1.It is not necessary for derived classes to override those functions

2.It is necessary for derived classes to override those functions

3.Those functions can never be derived

4.Those functions must be overridden by all the derived classes


Question:
In C# ________

1.Non – virtual or static methods can’t be overridden

2.Non – virtual and static methods only can be overridden

3.Overriding is not allowed

4.Overriding must be implemented using C++ code only


Question:
In java ________ takes care of managing memory for objects dynamically.

1. Free collector

2.Dust collector

3.Memory manager

4.Garbage collector


Question:
In java, which rule must be followed?

1.Keyword private preceding list of private member’s

2.Keyword private with a colon before list of private member’s

3. Keyword private with arrow before each private member

4.Keyword private preceding each private member


Question:
In Kotlin, the function to be overridden must be ______

1.Private

2.Open

3. Closed

4.Abstract


Question:
The functions to be overridden ____

1.Must be private in base class

2.Must not be private base class

3.Must be private in both derived and base class

4.Must not be private in both derived and base class


Question:
The memory allocated for an object ________

1.Can be only dynamic

2.Can be only static

3. Can be static or dynamic

4.Can’t be done using dynamic functions


Question:
Using new is type safe as ______

1.t require to be specified with type of data

2.It doesn’t require to be specified with type of data

3. It requires the name of data

4.It allocated memory for the data


Question:
What does memory allocation for objects mean?

1.Actual creation and memory allocation for object members

2.Creation of member functions

3. Creation of data members for a class

4.Actual creation and data declaration for object members


Question:
What is the syntax to overload an operator?

1.className::operator<operatorSymbol>(parameters)

2.className:operator<operatorSymbol>(parameters)

3.className.operator<operatorSymbol>(paramteres)

4.className->operator<operatorSymbol>(parameters)


Question:
What should be used to call the base class method from the derived class if function overriding is used in Java?

1.Keyword super

2.Scope resolution

3.Dot operator

4.Function name in parenthesis


Question:
When is the memory allocated for an object gets free?

1.At termination of program

2.When object goes out of scope

3.When main function ends

4.When system restarts


Question:
When is the memory allocated for an object?

1.At declaration of object

2.At compile time

3.When object constructor is called

4.When object is initialized to another object


Question:
When the friend operator overloading is converted into member operator overloading ____

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

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

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

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


Question:
When the operator to be overloaded becomes the left operand member then ______

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

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

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

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


Question:
Where in the parameter list is the implicit *this is added?

1.Right most parameter

2.Anywhere in parameter list

3.Left most parameter

4.Not added to parameter list


Question:
Which among the following are valid ways of overloading the operators?

1.Only using friend function

2.Only using member function

3.Either member functions or friend functions can be used

4.Operators can’t be overloaded


Question:
Which among the following is mandatory condition for operators overloading?

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

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

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

4.Overloaded operator must not be dependent on the operands


Question:
Which among the following is true?

1.The private members can’t be accessed by public members of the class

2.The private members can be accessed by public members of the class

3.The private members can be accessed only by the private members of the class

4. The private members can’t be accessed by the protected members of the class


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

1.delete

2.free

3.either delete or free

4.only delete


Question:
Which error will be produced if private members are accessed?

1.Can’t access private message

2.Code unreachable

3.Core dumped

4.Bad code


Question:
Which function among the following can’t be accessed outside the class in java in same package?

1. public void show()

2.void show()

3.protected show()

4. static void show()


Question:
Which function is called whenever an object goes out of scope?

1.Destructor function

2.Constructor function

3.Delete function

4.Free function


Question:
Which is private member functions access scope?

1.Member functions which can only be used within the class

2.Member functions which can used outside the class

3.Member functions which are accessible in derived class

4.Member functions which can’t be accessed inside the class


Question:
Which is the correct condition for function overriding?

1.The declaration must not be same in base and derived class

2.The declaration must be exactly the same in base and derived class

3.The declaration should have at least 1 same argument in declaration of base and derived class

4.The declaration should have at least 1 different argument in declaration of base and derived class


Question:
Which language doesn’t support the method overriding implicitly?

1. C++

2.C#

3. Java

4.SmallTalk


Question:
Which member can never be accessed by inherited classes?

1.Private member function

2.Public member function

3.Protected member function

4.All can be accessed


Question:
Which of the following function can be used for dynamic memory allocation of objects?

1.malloc()

2.calloc()

3.create()

4.both malloc() and calloc()


Question:
Which operator among the following can be overloading using only member function?

1.Assignment operator

2.Addition operator

3.Subtraction operator

4.Multiplication and division operator


Question:
Which operator can be used to check the size of an object?

1.sizeof(objectName)

2.size(objectName)

3. sizeofobject(objectName)

4. sizedobject(objectName)


Question:
Which syntax among the following shows that a member is private in a class?

1.private: functionName(parameters)

2.private(functionName(parameters))

3.private functionName(parameters)

4.private::functionName(parameters)


Question:
Why the left parameter is removed from parameter list?

1.Because it is of no use

2.Because it is never used in definitions

3. Because it becomes parameter pointed by *this

4.Because it can’t be referred by *this pointer


More MCQS

  1. OOPS Mcq Question Set 1
  2. OOPS Mcq Question Set 2
  3. OOPS Mcq Question Set 3
  4. OOPS Mcq Question Set 4
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!