28.4k views
5 votes
Write a public interface named Test with the following behavior: a method getDuration that returns a Duration object. a method check that accepts an int parameter and returns a Result object. a method getScore that returns a double.

User Pariola
by
6.4k points

1 Answer

5 votes

Answer:

The code to this question can be given as:

Code:

public interface Test

{

public abstract Duration getDuration();

public abstract Result check(int ar);

public abstract double getScore();

}

Step-by-step explanation:

An interface is similar to Java Class, and it has only static variables and abstract methods. Java uses a multi-inheritance interface. Many Java interfaces can be implemented by a Java class. All methodologies were implicitly public and abstract within an interface.

In the given question we a function that is "Test" and inside the interface, we define three functions that are defined as:

  • First, we declare a "getDuration" method that returns the Duration object.
  • Second, we declare a "check" method that accepts an integer variable that is "a".
  • Third, we declare a "getScore" method that returns a double value.

User Iesha
by
6.3k points