File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes has a relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "has a relationship" Watch "has a relationship" New topic
Author

has a relationship

parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
Hello friend
this is one more question form Sun exam
. Which two demonstrate a "has a" relationship? (Choose two.)
1) public interface Person{ }
public class Employee extends Person{ }
2) public interface Shape{ }
public interface Rectangle extends Shape{ }
3)public interface Colorable{ }
public class Shape implements Colorable{ }
4)public class Species{ }
public class Animal{private Species species;}
5)interface Component{ }
class Container implements Component{
private Component[] children;
}
Ans is 4,5.
I want to know more about has a relationship? and why the answer are correct?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3254
    
    2
This might help you: http://www.javaranch.com/ubb/Forum24/HTML/004960.html
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
Thanks Paul.
I understand is-a but can you elaborate on has-a relationship
parag
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
In the end, if something has-a whatever, there must be a place to keep that whatever. Therefore there must be a variable somewhere to keep the information for what it has.
In 4 the Animal has-a Species. The class has the information for the species and stores it in a variable of type Species. If it had read
public class Animal extends Species{}
then it would "be-a" Species.
In 5 it has-a Component array named children.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Anuj Anand
Ranch Hand

Joined: Nov 18, 2000
Posts: 96
When a class extends another class use 'is' a relation..If we are talking about attributes of a class like variables ,methods of a classs .There is a 'has a' relation.
For e.g A car is a vehicle.
A car has 4 wheels
so
class Car extends Vehicle
{
int wheels = 4
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: has a relationship
 
Similar Threads
sun sample question
Qn from Sun's samples
Sun qstns - "has a" relationship
Sun sample ques.
Help plz