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.