Skip to main content

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)

  Explain spiral development model with advantages and disadvantages The Spiral Development Model is a risk-driven software development approach that combines iterative and waterfall models. It involves repeated cycles (or spirals) to incrementally refine the software project. Each spiral consists of four major phases: Planning , Risk Analysis , Engineering , and Evaluation .                                                           Fig: Spiral Software development model Phases in the Spiral Model: Planning : Requirements are gathered and objectives are set for the project. Risk Analysis : Risks are identified, analyzed, and mitigation strategies are developed. Develop/Engineering : The actual development and testing of the product take place. Evaluation : Stakeholders/users review the progress and provide feedback, inf...

Solution of NEB model quetions

 solution to model questions are : 

DBMS-SQL

SQL DDL and DML Examples Examples of DDL (Data Definition Language) and DML (Data Manipulation Language) commands in SQL. DDL (Data Definition Language) Examples: 1. Create a new database: CREATE DATABASE SchoolDB;  2. Create a table: CREATE TABLE Students ( StudentID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Age INT );  3. Alter a table to add a new column: ALTER TABLE Students ADD Email VARCHAR(100);  4. Drop a table: DROP TABLE Students;  5. Rename a table: ALTER TABLE OldTableName RENAME TO NewTableName;  DML (Data Manipulation Language) Examples: 1. Insert data into a table:  INSERT INTO Students (StudentID, FirstName, LastName, Age) VALUES (1, 'John', 'Doe', 20);  2. Update data in a table: UPDATE Students SET Age = 21 WHERE StudentID = 1;  3. Delete data from a table: DELETE FROM Students WHERE StudentID = 1;  4. Select data from a table: SELECT * FROM Students;  5. Select data with conditions: SELECT FirstName...