permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface question from Khalid and Rasmussen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface question from Khalid and Rasmussen" Watch "Interface question from Khalid and Rasmussen" New topic
Author

Interface question from Khalid and Rasmussen

Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
Hi all,
In this book there is question 6.12 which is as follows:
Q. Which of these statements about interfaces are true?
Select all valid answers.
a) Interfaces permit multiple implementation inheritance.
b) Interfaces can be extended by any number of other interfaces.
c) Interfaces can extend any number of other interfaces.
d) Members of an interface are never static.
e) Members of an interface can always be defined static.

and the correct answer is : b and c
I don't understand how c is correct. Interfaces can IMPLEMENT many other interfaces, how can they EXTEND any number of interfaces?
does any one know why c is a valid statement?
Thanks
Lisa Yanchunis
Greenhorn

Joined: Nov 03, 2000
Posts: 27
Actually it is a quite common practice in the "real world"
Read the following thread for a common pattern in implementing beans
http://theserverside.com/patterns/thread.jsp?thread_id=1322
Lisa
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
Interfaces can be extended by any number of other interfaces.
Interfaces can extend any number of other interfaces.
Interfaces can IMPLEMENT many other interfaces- Wrong.
A class can implement many other interfaces but a interface can extend(not implement) other interfaces.
Prakshi Chopra
Greenhorn

Joined: Mar 05, 2001
Posts: 10
Originally posted by Seema Das:
Hi all,
In this book there is question 6.12 which is as follows:
Q. Which of these statements about interfaces are true?
Select all valid answers.
a) Interfaces permit multiple implementation inheritance.
b) Interfaces can be extended by any number of other interfaces.
c) Interfaces can extend any number of other interfaces.
d) Members of an interface are never static.
e) Members of an interface can always be defined static.

and the correct answer is : b and c
I don't understand how c is correct. Interfaces can IMPLEMENT many other interfaces, how can they EXTEND any number of interfaces?
does any one know why c is a valid statement?
Thanks

Prakshi Chopra
Greenhorn

Joined: Mar 05, 2001
Posts: 10
Originally posted by Seema Das:
Hi all,
In this book there is question 6.12 which is as follows:
Q. Which of these statements about interfaces are true?
Select all valid answers.
a) Interfaces permit multiple implementation inheritance.
b) Interfaces can be extended by any number of other interfaces.
c) Interfaces can extend any number of other interfaces.
d) Members of an interface are never static.
e) Members of an interface can always be defined static.

and the correct answer is : b and c
I don't understand how c is correct. Interfaces can IMPLEMENT many other interfaces, how can they EXTEND any number of interfaces?
does any one know why c is a valid statement?
Thanks

Yes as regard to Interfaces we can use multiple inheritance ( not multiple implementation inheritance )
Statement: interface mylistener extends windowListener, actionListener
is perfectly valid, because java allows multiple inheritance in case of interfaces and not in case of classes. For further detail see page 197 Extending Interfaces (khalid A Mughal)
Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
Thank you all!
All the information was really helpful.
-Seema
corneilguy
Greenhorn

Joined: Feb 03, 2001
Posts: 12
what is wrong with E) ?
Lisa Yanchunis
Greenhorn

Joined: Nov 03, 2000
Posts: 27
One other note:
Another common reason for extending rather than implementing an interface is that there may be only ONE method that you want to implement from an interface with a large number of methods. If you extend it you only have to implement the one method you want to use (as an overriding method) and don't have to implement the remainder as you would have to if you implemented it.
Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
Originally posted by corneilguy:
what is wrong with E) ?

mambers of interface are implicitly static. The variables are
implicitly public static final and methods are implicitly static. Thats why should not be declared as static.
Thanks
Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
Originally posted by Lisa Yanchunis:
One other note:
Another common reason for extending rather than implementing an interface is that there may be only ONE method that you want to implement from an interface with a large number of methods. If you extend it you only have to implement the one method you want to use (as an overriding method) and don't have to implement the remainder as you would have to if you implemented it.


Lisa,
but if you extend an interface and override just one method and do not give implementation for other methods, then I believe the class would need to be declared as abstract. am I right?

Thanks
Seema
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface question from Khalid and Rasmussen
 
Similar Threads
my question about interface?
Interface
Inheritance
Interface Theory
Requirement of Interface in Java