wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Sun sample ques. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Sun sample ques." Watch "Sun sample ques." New topic
Author

Sun sample ques.

Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
I was wondering why 4 and 5 are the correct answers?
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;
}
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
When determining if something is a "has a" relationship or an "is a" relationship look to see if it implements or extends a class or if it has a class or instance variable in the class. If it extends the class then you are saying that class A is a Class B. If you have an instance variable, then you are saying Class A has a Class B.
So for the example above, answer 4 and 5 both have instance variables of another class, so you can say Animal has a Species called species and Container has a Component called children.
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
Thanks for the answer, it seems clear now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sun sample ques.