Hi again,
There is one more question in Khalid and R.R. I am little confused with the answer. The q no. is 6.26 and it is as follows.
Q. Given the following code, which statements are true?
public interface HeavenlyBody {
String describe(); }
class Start {
String starName;
public String describe() { return "star " + starName; }
}
class Planet extends Star {
String name;
public String describe() {
return "Planet " + name + "orbiting star " + starname;
}
}
Select all valid answers.
a) ----
b) The use of inheritance is justified, since planet is-a star.
c) --
d) --
e) --
I thought option b is valid since class Planet extends class Star. but the book does not give b) as the valid answer. Their explanation is as follows:
The use of inheritance in this code is not justifiable, since conceptually, a planet is-not-a star.
Could anyone please tell me why Planet is-not-a star?
Thanks in advance.