In OOP, ______ is used to restrict access to certain details of an object.

A

Inheritance

B

Polymorphism

C

Abstraction

D

Encapsulation

উত্তরের বিবরণ

img

Answer: ) Encapsulation
 Explanation:
Encapsulation in Object-Oriented Programming (OOP):

Definition: Wrapping data (attributes) and methods (functions) that operate on the data into a single unit (class) and restricting access to some of the object’s components.
Purpose: Protects object integrity by preventing unauthorized access or modification.
 
Example:
 
class BankAccount {
private:
    double balance; // cannot be accessed directly outside the class

public:
    void deposit(double amount) { balance += amount; }
    double getBalance() { return balance; }
};

balance is hidden (private) → can only be accessed via methods → encapsulation.
 
Other options are incorrect:

) Inheritance→→Allows a class to derive properties from another class
) Polymorphism→→Allows one interface, multiple forms
) Abstraction→→Hides implementation details but focuses on what an object does, not access control

 

Unfavorite

0

Updated: 2 days ago

Related MCQ

 Find the output of the following code snippet:

#include

#define MULTIPLY(a,b) a/b

int main(){

  int x=5, y=2, result; 

  result = MULTIPLY(y+x,y+x);

  printf("%d",result);

  return 0;

Created: 2 days ago

A

1

B

7

C

9

D

Runtime error

Unfavorite

0

Updated: 2 days ago

 A complete graph of n vertices has ______ edges. 

Created: 2 days ago

A

n

B

n(n+1)/2

C

n(n-1)/2 

D

n2

© LXMCQ, Inc. - All Rights Reserved

Developed by WiztecBD