Oops Concepts(C++ Programming ) Questions and Answers

Question 1.

Which of the following statement is correct?


  1.    Class is an instance of object.
  2.    Object is an instance of a class.
  3.    Class is an instance of data type.
  4.    Object is an instance of data type.
Explanation:-
Answer: Option B. -> Object is an instance of a class.



Question 2.

Which of the following provides a reuse mechanism?


  1.    Abstraction
  2.    Inheritance
  3.    Dynamic binding
  4.    Encapsulation
Explanation:-
Answer: Option B. -> Inheritance



Question 3.

What is correct about the static data member of a class?


  1.    A static member function can access only static data members of a class.
  2.    A static data member is shared among all the object of the class.
  3.    A static data member can be accessed directly from main().
  4.    Both A and B.
Explanation:-
Answer: Option D. -> Both A and B.



Question 4.

Which of the following is used to make an abstract class?


  1.    Declaring it abstract using static keyword.
  2.    Declaring it abstract using virtual keyword.
  3.    Making at least one member function as virtual function.
  4.    Making at least one member function as pure virtual function.
Explanation:-
Answer: Option D. -> Making at least one member function as pure virtual function.



Question 5.

Which of the following access specifier is used as a default in a class definition?


  1.    protected
  2.    public
  3.    private
  4.    friend
Explanation:-
Answer: Option C. -> private



Question 6.

Which one of the following options is correct?


  1.    Friend function can access public data members of the class.
  2.    Friend function can access protected data members of the class.
  3.    Friend function can access private data members of the class.
  4.    All of the above.
Explanation:-
Answer: Option D. -> All of the above.



Question 7.


Which inheritance type is used in the class given below?


class A : public X, public Y
{}
  1.    Multilevel inheritance
  2.    Multiple inheritance
  3.    Hybrid inheritance
  4.    Hierarchical Inheritance
Explanation:-
Answer: Option B. -> Multiple inheritance



Question 8.

Which one of the following is correct about the statements given below?

        1. All function calls are resolved at compile-time in Procedure Oriented Programming.

        2. All function calls are resolved at compile-time in OOPS.


  1.    Only II is correct.
  2.    Both I and II are correct.
  3.    Only I is correct.
  4.    Both I and II are incorrect.
Explanation:-
Answer: Option C. -> Only I is correct.



Question 9.

Which of the following is an invalid visibility label while inheriting a class?


  1.    public
  2.    private
  3.    protected
  4.    friend
Explanation:-
Answer: Option D. -> friend



Question 10.

Which of the following statements is correct in C++?


  1.    Classes cannot have data as protected members.
  2.    Structures can have functions as members.
  3.    Class members are public by default.
  4.    Structure members are private by default.
Explanation:-
Answer: Option B. -> Structures can have functions as members.