WorksheetsTopic 2 APP Quiz
Total questions: 8
Worksheet time: 5mins
What is encapsulation in Object-Oriented Programming (OOP)
Grouping related methods and variables in a single unit
Allowing access to methods and variables from anywhere in the program
Hiding the internal details of an object and exposing only what is necessary
A technique to define multiple methods with the same name
Which access modifier is typically used to achieve encapsulation?
public
private
protected
final
What is the main purpose of inheritance in OOP?
To create private variables
To reuse existing code in new classes
To make variables accessible everywhere
To declare methods with the same name
Encapsulation helps in improving the maintainability and flexibility of code
True
False
A subclass automatically inherits private fields from its superclass
True
False
In inheritance, the class that inherits from another class is called the (a) .
Encapsulation is achieved using ___________ fields and providing ______________ methods to access them.
(a)
You are developing a banking application. Which OOP concepts are best suited to restrict direct access to account balance and provide controlled access through methods?
Polymorphism
Inheritance
Encapsulation
Abstraction
