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.
			
			
									
									
						question on enthuware.ocpjp.v8.2.1251
Moderator: admin
- 
				Asymmetriccat
 - Posts: 3
 - Joined: Mon Jun 12, 2017 1:13 pm
 - Contact:
 
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: question on enthuware.ocpjp.v8.2.1251
Implementing a method means having code for the method. It does not imply having an implements clause. For example, the following interface can be said to implement the method add:
public interface Interface{
default int add(int a, int b){ };
}
On the other hand, "implementing an interface" means having an implements clause.
			
			
									
									
						public interface Interface{
default int add(int a, int b){ };
}
On the other hand, "implementing an interface" means having an implements clause.
- 
				Asymmetriccat
 - Posts: 3
 - Joined: Mon Jun 12, 2017 1:13 pm
 - Contact:
 
Re: question on enthuware.ocpjp.v8.2.1251
Sounds making sense. Thanks a lot!!!
			
			
									
									
						admin wrote:Implementing a method means having code for the method. It does not imply having an implements clause. For example, the following interface can be said to implement the method add:
public interface Interface{
default int add(int a, int b){ };
}
On the other hand, "implementing an interface" means having an implements clause.
Who is online
Users browsing this forum: No registered users and 44 guests