Which of the following sets of statements are acceptable def

Which of the following sets of statements are acceptable definitions for an inteface?


(I)                                                                                    (II)
public abstract interface X                                          public interface X
{                                                                                      {
          int MAX = 200;                                                              int MAX = 200;  
          double print(int y);                                                       double print(int y)
}                                                                                       }

(III)                                                                                   (IV)
public interface X                                                        public interface X
{                                                                                       {
          public static final int MAX = 200;                             static int MAX = 200;  
          public abstract double print(int y);                           abstract double print(int y)
}                                                                                       }   

(V)
public interface X
{
               public static final int MAX = 200;
               public abstract double print(int y)
              {
                       return 0;
              }
}

SELECT ALL POSSIBLE RESPONSES

Select one or more:

a. (III)

b. (IV)

c. (II)

d. (I)

e. (V)

Solution

Answer:

b. (IV)

c. (II)

a. (III)

These three are the correct way of definitions of an interface.

I. Issue with first definition is we can not create interface with abstract keyword.

public abstract interface X
{   
          int MAX = 200;   
          double print(int y);   
}   

(V) Issue with fifth definition is we can not implement the method in interfaces. it should contain abstract methods. abstract method is nothing but no implementation and only declaration.
public interface X
{
               public static final int MAX = 200;
               public abstract double print(int y)
              {
                       return 0;
              }
}

Which of the following sets of statements are acceptable definitions for an inteface? (I) (II) public abstract interface X public interface X { { int MAX = 200;
Which of the following sets of statements are acceptable definitions for an inteface? (I) (II) public abstract interface X public interface X { { int MAX = 200;

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site