This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes sun sample question 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 "sun sample question " Watch "sun sample question " New topic
Author

sun sample question

Satheesh Kumar
Greenhorn

Joined: Nov 21, 2000
Posts: 14
Hai
I found this question in "sun site " for "has a " relationship..,
now can anyody help me out in this question

Which two demonstrate a "is a" relationship?
a. public interface Person{ }
public class Employee extends Person{ }
b. public interface Shape{ }
public interface Rectangle extends Shape{ }
c. public interface Colorable{ }
public class Shape implements Colorable{ }
d. public class Species{ }
public class Animal{private Species species;}
e. interface Component{ }
class Container implements Component{
private Component[] children;
}
Rajiv Ranjan
Ranch Hand

Joined: Sep 28, 2000
Posts: 61
I will go for a, b and c.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
The difference between "is a" and "has a" is whether or not you extend another class, or just have member variable of the class.
So if Employee extends Person, then you are saying the Employee is a Person becuase they have all the behaviors of the Person, or they inherit all of the methods of class Person.
But if you have a class Employee and in that class is a memeber variable Person, you are saying Employee has a Person because inside of thier class they have another class Person.
Implements is sometimes called "is like a" but it is also really an "is a" becuase you have to implement all of the methods to make it a class otherwise it has to be an abstract class or another interface.
With all that said, take a look at it again, and see if you can figure out the answer.
Bill
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
One more thing, the Sun question asks which TWO represent a HAS A relationship, not is a. Don't want to confuse people because there are 3 is a and 2 has a.
Bill
Satheesh Kumar
Greenhorn

Joined: Nov 21, 2000
Posts: 14
Thanks Bill and Rajiv
I did not mean to confuse people, but my question was to get an answer for "is a" relation
If I had done so.., I am extremely sorry..,
Thanks for the explanation, now I am clear with the ans

Originally posted by Satheesh Kumar:
Hai
I found this question in "sun site " for "has a " relationship..,
now can anyody help me out in this question

Which two demonstrate a "is a" relationship?
a. public interface Person{ }
public class Employee extends Person{ }
b. public interface Shape{ }
public interface Rectangle extends Shape{ }
c. public interface Colorable{ }
public class Shape implements Colorable{ }
d. public class Species{ }
public class Animal{private Species species;}
e. interface Component{ }
class Container implements Component{
private Component[] children;
}

Kirti Dhingra
Ranch Hand

Joined: Dec 13, 2000
Posts: 32
answer is D & E b'coz they contain a member variable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sun sample question
 
Similar Threads
Qn from Sun's samples
"has a" relationship question
Sun qstns - "has a" relationship
Sun sample ques.
has a relationship