*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes is-a Relation Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "is-a Relation Question" Watch "is-a Relation Question" New topic
Author

is-a Relation Question

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Given the following code, which statements are true?


Options
a. Class B implements interface A.
b. Class B is-a A.
c. class B has-a A


Question: Whether option "b" is correct.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
Hmm.. vishnu! I would like to know from where did you get the question? Hope you are not trying to replicate the following thread...

http://www.coderanch.com/t/249665/java-programmer-SCJP/certification/Implementing-interface-it


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
The notion of IS-A is independent of Java. Java types that extend a class or implement an interface have an IS-A relationship with the class or interface. If you implement Duck you're a duck; if you extend Duck you're a Duck. Simple.
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
Originally posted by Rick O'Shay:
The notion of IS-A is independent of Java. Java types that extend a class or implement an interface have an IS-A relationship with the class or interface. If you implement Duck you're a duck; if you extend Duck you're a Duck. Simple.


In code, this would look like this:




It doesn't matter whether A is an interface that B implements, or whether B is a subclass of A. Regardless, B does eveything that an A can, so B is an A.

Todd Farmer
 
jQuery in Action, 2nd edition
 
subject: is-a Relation Question