OOP MCQS

 What is the primary concept behind Object-Oriented Programming (OOP)?

a. Procedural programming

b. Code optimization

c. Data and behavior encapsulation

d. Functional programming


Answer: c. Data and behavior encapsulation


In OOP, what is an object?

a. A function

b. A data type

c. An instance of a class with both data and methods

d. A variable


Answer: c. An instance of a class with both data and methods


What is a class in OOP?

a. A blueprint or template for creating objects

b. An instance of an object

c. A data structure

d. A function


Answer: a. A blueprint or template for creating objects


What is the process of creating an object from a class called in OOP?

a. Instantiation

b. Declaration

c. Inheritance

d. Encapsulation


Answer: a. Instantiation


Which OOP principle allows a class to inherit the properties and methods of another class?

a. Abstraction

b. Polymorphism

c. Inheritance

d. Encapsulation


Answer: c. Inheritance


What is the term for the ability of different classes to be treated as objects of a common superclass in OOP?

a. Polymorphism

b. Encapsulation

c. Abstraction

d. Inheritance


Answer: a. Polymorphism


What is the primary purpose of encapsulation in OOP?

a. To hide implementation details and provide a public interface

b. To create multiple instances of a class

c. To perform mathematical calculations

d. To inherit properties from a superclass


Answer: a. To hide implementation details and provide a public interface


In OOP, what are access modifiers used for?

a. To define the data type of a variable

b. To specify the return type of a method

c. To control the visibility and accessibility of class members

d. To create objects from classes


Answer: c. To control the visibility and accessibility of class members


Which of the following is NOT an access modifier in OOP?

a. Public

b. Private

c. Protected

d. Final


Answer: d. Final


What is the concept of defining a new class based on an existing class in OOP?

a. Inheritance

b. Encapsulation

c. Polymorphism

d. Abstraction


Answer: a. Inheritance


What is a constructor in OOP?

a. A method that initializes the state of an object

b. A method that destructs an object

c. A method that copies an object

d. A method that updates an object's data


Answer: a. A method that initializes the state of an object


In OOP, what is method overloading?

a. Defining a method with the same name but different parameters in the same class

b. Inheriting methods from a superclass

c. Defining a method with multiple return values

d. Hiding implementation details of a method


Answer: a. Defining a method with the same name but different parameters in the same class


Which OOP concept allows you to define a generic blueprint for a class with placeholders for data types?

a. Inheritance

b. Encapsulation

c. Polymorphism

d. Generics


Answer: d. Generics


What is the concept of restricting the modification of certain properties or methods in OOP?

a. Encapsulation

b. Abstraction

c. Inheritance

d. Polymorphism


Answer: a. Encapsulation


Which OOP principle involves defining the common characteristics and behaviors of a group of objects in a superclass?

a. Polymorphism

b. Encapsulation

c. Inheritance

d. Abstraction


Answer: c. Inheritance


What is the term for a method that has the same name in different classes but performs different actions?

a. Overloading

b. Overriding

c. Polymorphism

d. Abstraction


Answer: b. Overriding


In OOP, what is a static method?

a. A method that cannot be called without creating an object of the class

b. A method that is automatically called when an object is created

c. A method that belongs to the class rather than an instance of the class

d. A method that cannot be overridden


Answer: c. A method that belongs to the class rather than an instance of the class


What is the term for a class that cannot be instantiated in OOP and is often used as a base class for other classes?

a. Abstract class

b. Final class

c. Static class

d. Concrete class


Answer: a. Abstract class


Which OOP concept allows you to define a template with placeholders for types that can be filled in later?

a. Generics

b. Abstraction

c. Inheritance

d. Encapsulation


Answer: a. Generics


In OOP, what is the purpose of a destructor?

a. To initialize an object

b. To copy an object

c. To clean up resources and release memory when an object is destroyed

d. To hide implementation details of a class


Answer: c. To clean up resources and release memory when an object is destroyed


What is the main advantage of polymorphism in Object-Oriented Programming (OOP)?


a) Code reusability

b) Increased program speed

c) Reduced memory usage

d) Enhanced data encryption


Answer: a) Code reusability

Comments

Popular posts from this blog

Software Process Model(SPM)

C PROGRAM(structure) EXAMPLES