Question:

A/An ................ in Java is a block of statements grouped together to perform a specific task.

Show Hint

In Java, a method groups related statements to perform a specific action.
Updated On: Jul 14, 2025
  • Array
  • Object
  • Class
  • Method
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

In Java, a method is a block of code that performs a specific task.
Methods are used to group multiple statements into a single unit so that the code can be reused and organized efficiently.
They are defined within classes and can be invoked when needed to perform operations.
The syntax of a method includes the return type, method name, and parameters (if any).
For example: int add(int a, int b) { return a + b; }
Arrays, objects, and classes are other core components of Java, but only a method defines a task-performing code block.
Hence, the correct answer is (D) Method.
Was this answer helpful?
0
0