question on enthuware.ocpjp.v8.2.1251
Posted: Mon Jun 12, 2017 1:47 pm
Hello,
I have difficulty to understand the question as in the title, also as below. Can anybody help? In the explanation, it mentioned: "It is given that A implements a method. Since Java 8 allows interfaces to contain method implementation as well, that means it can be a class or an interface. Further, it is given that A declares a method but does not implement it, that means, if it is a class, it must be an abstract class."
But I have not see that any interface could implements any method in another interface so far. I tried writing such kind code in Eclipse but got compiling error.
public interface InterfaceImplement extends A{
int add(int a, int b){}; //compiling error in this line
}
interface A{
int add(int a, int b);
}
Can anybody provide a solid example for better understanding? Thanks a lot in advance!
Original question as below:
Given:
Type A is a template for other types in the application.
Type A implements method process().
Type A declares but does not implement method prepare().
Which of the following statements are correct?
a. A must be an interface.
b. A must be an abstract class.
c. A may be an abstract class or an interface.
d. A must implement an interface.
c is the answer from Enthuware.
I have difficulty to understand the question as in the title, also as below. Can anybody help? In the explanation, it mentioned: "It is given that A implements a method. Since Java 8 allows interfaces to contain method implementation as well, that means it can be a class or an interface. Further, it is given that A declares a method but does not implement it, that means, if it is a class, it must be an abstract class."
But I have not see that any interface could implements any method in another interface so far. I tried writing such kind code in Eclipse but got compiling error.
public interface InterfaceImplement extends A{
int add(int a, int b){}; //compiling error in this line
}
interface A{
int add(int a, int b);
}
Can anybody provide a solid example for better understanding? Thanks a lot in advance!
Original question as below:
Given:
Type A is a template for other types in the application.
Type A implements method process().
Type A declares but does not implement method prepare().
Which of the following statements are correct?
a. A must be an interface.
b. A must be an abstract class.
c. A may be an abstract class or an interface.
d. A must implement an interface.
c is the answer from Enthuware.