WorksheetsJava OOP
Total questions: 10
Worksheet time: 7mins
What is the keyword used to inherit a class in Java?
implement
inherit
extends
interface
Which access modifier restricts access to a class member to within its own package?
private
protected
public
default
Which of the following best describes encapsulation in Java?
Creating multiple methods with the same name but different parameters
Inheriting properties and behaviors from another class
Hiding the implementation details of a class and only providing access through public methods
Grouping related data and methods into a single unit
What is the purpose of the "this" keyword in Java?
Refers to the current instance of the class
Refers to the superclass of the class
Refers to the subclass of the class
Refers to the parent class of the class
Which keyword is used to prevent a method from being overridden in a subclass?
final
abstract
private
static
What is the process of defining a method in a subclass with the same name and parameters as a method in the superclass called?
Overloading
Overriding
Extending
Implementing
Which keyword is used to indicate that a method has no return value in Java?
void
null
empty
return
Which of the following best describes polymorphism in Java?
Ability to take multiple forms
Hiding the implementation details of a class
Grouping related data and methods into a single unit
Inheriting properties and behaviors from another class
What is the purpose of abstraction in Java?
The purpose of abstraction is to hide the implementation details of complex systems and allow the use of simplified and generalized concepts.
Creating multiple methods with the same name but different parameters
Grouping related data and methods into a single unit
Inheriting properties and behaviors from another class
What are the four main principles of Object-Oriented Programming (OOP) in Java?
Abstraction, Encapsulation, Inheritance, Composition
Encapsulation, Inheritance, Polymorphism, Abstraction
Encapsulation, Modularity, Polymorphism, Inheritance
Inheritance, Encapsulation, Polymorphism, Modularity
