0% found this document useful (0 votes)
68 views9 pages

30 Basic and Core MCQs On OOP

Uploaded by

mksaifi736
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views9 pages

30 Basic and Core MCQs On OOP

Uploaded by

mksaifi736
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Here are 30 basic and core MCQs on Object-Oriented Programming (OOP) for your

comprehensive MCS exam:

Basic Concepts

1. Which of the following is not a feature of OOP?


o a) Encapsulation
o b) Polymorphism
o c) Inheritance
o d) Compilation
2. What does encapsulation mean?
o a) Bundling data and methods that operate on the data within a single unit
o b) Deriving a new class from an existing class
o c) Hiding the implementation details from the user
o d) Allowing a function to take on many forms
3. Which of the following is not a pillar of OOP?
o a) Abstraction
o b) Inheritance
o c) Compilation
o d) Polymorphism
4. Which keyword is used to create an object in C++?
o a) create
o b) new
o c) class
o d) object
5. In OOP, what does inheritance allow?
o a) Modifying the data in a class
o b) Creating a new class from an existing class
o c) Destroying objects
o d) Overloading operators

Class and Object

6. Which of the following statements is true about a class?


o a) A class is a blueprint for objects
o b) A class is an object itself
o c) A class only contains data
o d) A class cannot have methods
7. Which of the following can access private data members of a class?
o a) Any function in the program
o b) Only member functions of the same class
o c) Only friend functions
o d) Both b and c
8. What is a constructor?
o a) A special type of method that is automatically invoked when an object is
created
o b) A method that destroys an object
o c) A method that converts one type of data to another
o d) A method that is used to overload operators
9. What is a destructor in C++?
o a) A special method used to deallocate memory
o b) A method to construct objects
o c) A method that is used to create arrays
o d) A method to initialize data members
10. Which of the following is a valid way to define an object of a class Car?
o a) Car obj;
o b) Car.obj;
o c) Car-obj;
o d) obj Car;

Inheritance

11. Which type of inheritance involves a single class being inherited by multiple classes?
o a) Single inheritance
o b) Multiple inheritance
o c) Multilevel inheritance
o d) Hierarchical inheritance
12. What is the correct syntax for creating a derived class in C++?
o a) class Derived : public Base
o b) class Base : Derived
o c) class Derived -> Base
o d) class Base = Derived
13. Which access specifier restricts access to the class members to the derived class
only?
o a) Public
o b) Private
o c) Protected
o d) Internal
14. Which of the following is true about multiple inheritance?
o a) A class can inherit from multiple classes
o b) It is not allowed in C++
o c) It is not allowed in Python
o d) A class can inherit from only one class
15. What is the order of constructor calls in multilevel inheritance?
o a) Derived class first, then base class
o b) Base class first, then derived class
o c) It depends on the programming language
o d) Simultaneous for both classes
Polymorphism

16. Which of the following best defines polymorphism?


o a) Ability of a message to be displayed in multiple forms
o b) Ability to inherit from multiple classes
o c) Ability to hide data from the user
o d) Ability to overload functions
17. Which function is used to achieve polymorphism in C++?
o a) Constructor
o b) Destructor
o c) Virtual function
o d) Friend function
18. What is the difference between function overloading and function overriding?
o a) Overloading allows the same function to have different implementations, while
overriding allows different classes to have functions with the same name
o b) Overloading occurs within a class, while overriding occurs in derived classes
o c) Overloading is done at runtime, overriding at compile-time
o d) There is no difference between the two
19. Which of the following is true about virtual functions?
o a) They allow derived classes to override base class functions
o b) They are called using the base class reference
o c) They are resolved at runtime
o d) All of the above
20. Which of the following keywords is used to prevent further inheritance of a class?
o a) final
o b) static
o c) sealed
o d) const

Advanced Concepts

21. What is the purpose of an abstract class in OOP?


o a) To define a blueprint for other classes
o b) To create objects directly
o c) To provide concrete implementations for methods
o d) To prevent inheritance
22. How is dynamic binding achieved in OOP?
o a) Using virtual functions
o b) Using static functions
o c) Using constructors
o d) Using friend functions
23. Which of the following best describes operator overloading?
o a) Providing new implementations for existing operators
o b) Using multiple operators in a single expression
o c) Creating custom operators
o d) Restricting the use of certain operators
24. What is a pure virtual function?
o a) A function that does not have an implementation in the base class
o b) A function that must be overridden by derived classes
o c) A function that cannot be used in derived classes
o d) Both a and b
25. In Python, what is the method __init__() used for?
o a) To initialize an object when it is created
o b) To destroy an object when it is deleted
o c) To overload operators
o d) To create class methods

Miscellaneous

26. Which of the following statements about friend functions is true?


o a) They can access private and protected members of the class
o b) They are members of the class
o c) They are inherited by derived classes
o d) They cannot be accessed outside the class
27. What does the term "method overloading" refer to in Python?
o a) Having multiple methods in a class with the same name but different
parameters
o b) Having methods in a class with the same name and the same parameters
o c) Overriding methods from the base class
o d) Using default arguments in a method
28. Which of the following is not true about a static member in C++?
o a) It is shared among all objects of the class
o b) It is initialized only once
o c) It cannot be accessed without an object of the class
o d) It can be accessed using the class name
29. In Python, what is self used for?
o a) Referring to the class itself
o b) Referring to the instance of the class
o c) Referring to a global variable
o d) Referring to the superclass
30. Which of the following is true about the use of namespaces in C++?
o a) They allow the organization of code into logical groups
o b) They prevent name conflicts in large projects
o c) They allow multiple functions to have the same name in different contexts
o d) All of the above

These questions cover a wide range of OOP concepts and should be helpful for your
comprehensive exam preparation.

4o
mentions ansewers also
ChatGPT

Here are the 30 basic and core MCQs on Object-Oriented Programming (OOP) along with their
answers:

Basic Concepts

1. Which of the following is not a feature of OOP?


o a) Encapsulation
o b) Polymorphism
o c) Inheritance
o d) Compilation
2. What does encapsulation mean?
o a) Bundling data and methods that operate on the data within a single unit
o b) Deriving a new class from an existing class
o c) Hiding the implementation details from the user
o d) Allowing a function to take on many forms
3. Which of the following is not a pillar of OOP?
o a) Abstraction
o b) Inheritance
o c) Compilation
o d) Polymorphism
4. Which keyword is used to create an object in C++?
o a) create
o b) new
o c) class
o d) object
5. In OOP, what does inheritance allow?
o a) Modifying the data in a class
o b) Creating a new class from an existing class
o c) Destroying objects
o d) Overloading operators

Class and Object

6. Which of the following statements is true about a class?


o a) A class is a blueprint for objects
o b) A class is an object itself
o c) A class only contains data
o d) A class cannot have methods
7. Which of the following can access private data members of a class?
o a) Any function in the program
o b) Only member functions of the same class
o c) Only friend functions
o d) Both b and c
8. What is a constructor?
o a) A special type of method that is automatically invoked when an object is
created
o b) A method that destroys an object
o c) A method that converts one type of data to another
o d) A method that is used to overload operators
9. What is a destructor in C++?
o a) A special method used to deallocate memory
o b) A method to construct objects
o c) A method that is used to create arrays
o d) A method to initialize data members
10. Which of the following is a valid way to define an object of a class Car?
o a) Car obj;
o b) Car.obj;
o c) Car-obj;
o d) obj Car;

Inheritance

11. Which type of inheritance involves a single class being inherited by multiple classes?
o a) Single inheritance
o b) Multiple inheritance
o c) Multilevel inheritance
o d) Hierarchical inheritance
12. What is the correct syntax for creating a derived class in C++?
o a) class Derived : public Base
o b) class Base : Derived
o c) class Derived -> Base
o d) class Base = Derived
13. Which access specifier restricts access to the class members to the derived class
only?
o a) Public
o b) Private
o c) Protected
o d) Internal
14. Which of the following is true about multiple inheritance?
o a) A class can inherit from multiple classes
o b) It is not allowed in C++
o c) It is not allowed in Python
o d) A class can inherit from only one class
15. What is the order of constructor calls in multilevel inheritance?
o a) Derived class first, then base class
o b) Base class first, then derived class
o c) It depends on the programming language
o d) Simultaneous for both classes

Polymorphism

16. Which of the following best defines polymorphism?


o a) Ability of a message to be displayed in multiple forms
o b) Ability to inherit from multiple classes
o c) Ability to hide data from the user
o d) Ability to overload functions
17. Which function is used to achieve polymorphism in C++?
o a) Constructor
o b) Destructor
o c) Virtual function
o d) Friend function
18. What is the difference between function overloading and function overriding?
o a) Overloading allows the same function to have different implementations,
while overriding allows different classes to have functions with the same
name
o b) Overloading occurs within a class, while overriding occurs in derived
classes
o c) Overloading is done at runtime, overriding at compile-time
o d) There is no difference between the two
19. Which of the following is true about virtual functions?
o a) They allow derived classes to override base class functions
o b) They are called using the base class reference
o c) They are resolved at runtime
o d) All of the above
20. Which of the following keywords is used to prevent further inheritance of a class?
o a) final
o b) static
o c) sealed
o d) const

Advanced Concepts

21. What is the purpose of an abstract class in OOP?


o a) To define a blueprint for other classes
o b) To create objects directly
o c) To provide concrete implementations for methods
o d) To prevent inheritance
22. How is dynamic binding achieved in OOP?
o a) Using virtual functions
o b) Using static functions
o c) Using constructors
o d) Using friend functions
23. Which of the following best describes operator overloading?
o a) Providing new implementations for existing operators
o b) Using multiple operators in a single expression
o c) Creating custom operators
o d) Restricting the use of certain operators
24. What is a pure virtual function?
o a) A function that does not have an implementation in the base class
o b) A function that must be overridden by derived classes
o c) A function that cannot be used in derived classes
o d) Both a and b
25. In Python, what is the method __init__() used for?
o a) To initialize an object when it is created
o b) To destroy an object when it is deleted
o c) To overload operators
o d) To create class methods

Miscellaneous

26. Which of the following statements about friend functions is true?


o a) They can access private and protected members of the class
o b) They are members of the class
o c) They are inherited by derived classes
o d) They cannot be accessed outside the class
27. What does the term "method overloading" refer to in Python?
o a) Having multiple methods in a class with the same name but different
parameters
o b) Having methods in a class with the same name and the same parameters
o c) Overriding methods from the base class
o d) Using default arguments in a method
28. Which of the following is not true about a static member in C++?
o a) It is shared among all objects of the class
o b) It is initialized only once
o c) It cannot be accessed without an object of the class
o d) It can be accessed using the class name
29. In Python, what is self used for?
o a) Referring to the class itself
o b) Referring to the instance of the class
o c) Referring to a global variable
o d) Referring to the superclass
30. Which of the following is true about the use of namespaces in C++?
o a) They allow the organization of code into logical groups
o b) They prevent name conflicts in large projects
o c) They allow multiple functions to have the same name in different contexts
o d) All of the above

You might also like