Hi Sang,

In studying the Example 3 (Polymorphic behavior via Java Interface) in the 
Polymorphism lab of Javase, there is an interface class defined as follows:

public interface BookInterface extends ProductInterface { 
public String getPublisher();
public void setPublisher(String publisher);
public int getYearPublished();
public void setYearPublished(int yearPublished);
} 

Why does this class need to extend ProductInterface? I ask because Product 
class already implements ProductInterface. So when you define the Book 
class as:

public class Book extends Product* implements BookInterface*{ ...}

...it seems as though the Book class inherits ProductInterface twice: once 
from extending Product and again in the BookInterface implementation.

*I modified the BookInterface definition by removing extends 
ProductInterface and the code runs fine without error.

*So my questions are: 
Is there a reason you extend BookInterface with ProductInterface? Or is 
this simply superfluous coding? 

And why does the compiler not complain in Book class that it inherits 
ProductInterface interface twice: once from Product and again from 
BookInterface? Is it Ok to inherit the same abstract methods twice like 
this? 

Joel 

-- 
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/jpassion_java?hl=en-US.


Reply via email to