1.0k views
5 votes
A collection of related methods whose headers are provided without implementation:

a) Abstract class
b) Concrete class
c) Interface
d) Subclass

User Bilkis
by
7.7k points

1 Answer

2 votes

Final answer:

The correct answer is c) Interface. An interface in a programming language is a collection of related methods whose headers are provided without implementation. It acts as a contract that specifies what methods a class must implement.

Step-by-step explanation:

The correct answer to the question is c) Interface.

An interface in a programming language is a collection of related methods whose headers are provided without implementation. An interface acts as a contract that specifies what methods a class must implement. It defines the required behavior that any class implementing the interface must adhere to.

For example, in Java, you can define an interface using the 'interface' keyword. Here's an example of an interface called 'Shape' with a method 'calculateArea()':

public interface Shape {
double calculateArea();
}

Any class that implements the 'Shape' interface must provide an implementation of the 'calculateArea()' method. This allows for polymorphism, where different classes can be treated interchangeably based on their shared interface.

User Jeeyoungk
by
7.8k points