Explore topic-wise MCQs in Object Oriented Programming.

This section includes 15 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

All the public member functions ___________________

A. Can’t access the private members of a class
B. Can’t access the protected members of a class
C. Can access only public members of a class
D. Can access all the member of its class
Answer» E.
2.

The function main() must always be public.

A. True
B. False
Answer» B. False
3.

If a class have a public member function and is called directly in the main function then ___________________________

A. Undeclared function error will be produced
B. Out of memory error is given
C. Program gives warning only
D. Program shut down the computer
Answer» B. Out of memory error is given
4.

A derived class object can access the public members of the base class.

A. True
B. False
Answer» C.
5.

If public members are to be restricted from getting inherited from the subclass of the class containing that function, which alternative is best?

A. Make the function private
B. Use private inheritance
C. Use public inheritance
D. Use protected inheritance
Answer» C. Use public inheritance
6.

Which public function call among the following is correct outside the class, if return type is void (C++)?

A. object.void functionName(parameters);
B. object.functionName(parameters);
C. object.functionName void (parameters)
D. object.void functionName();
Answer» C. object.functionName void (parameters)
7.

Which call is correct for public members of a nested class?

A. Can be called from object of enclosing class
B. Can be called within enclosing class only with direct names
C. Direct names should be used for the nested classes
D. Only with help of nested class object pointer
Answer» B. Can be called within enclosing class only with direct names
8.

Which is not a proper way to access public members of a class?

A. Using object pointer with arrow operator
B. Using object of class in main function
C. Using object of class with arrow operator
D. Using object anywhere in the program
Answer» D. Using object anywhere in the program
9.

How many public members are allowed in a class?

A. Only 1
B. At most 7
C. Exactly 3
D. As many as required
Answer» E.
10.

In java, which rule among the following is applicable?

A. Keyword public can’t be preceded with all the public members
B. Keyword public must be preceded with all the public members
C. Keyword public must be post mentioned the function declaration
D. Keyword public is not mandatory
Answer» C. Keyword public must be post mentioned the function declaration
11.

Which syntax is applicable to declare public member functions in C++?

A. public: <function declaration>
B. public(<function declaration>)
C. public void <function declaration>
D. public::<function declaration>
Answer» B. public(<function declaration>)
12.

Which syntax among the following is correct for public member functions?

A. public::void functionName(parameters)
B. public void functionName(parameters)
C. public(void functionName(parameters))
D. public:-void functionName(Parameters)
Answer» C. public(void functionName(parameters))
13.

Which type of member functions get inherited in the same specifier in which the inheritance is done? (If private inheritance is used, those become private and if public used, those become public)

A. Private member functions
B. Protected member functions
C. Private member functionsb) Protected member functionsc) Public member functions
D. All member functions
Answer» D. All member functions
14.

Which among the following is true for public member functions?

A. Public member functions doesn’t have a return type
B. Public member functions doesn’t have any security
C. Public member functions are declared outside the class
D. Public member functions can be called using object of class
Answer» E.
15.

What are public member functions?

A. Functions accessible outside the class but not in derived class
B. Functions accessible outside the class directly
C. Functions accessible everywhere using object of class
D. Functions that can’t be accessed outside the class
Answer» D. Functions that can’t be accessed outside the class