Answer:

No. Valentine val and Holiday are siblings. Since they are not related by inheritance, a reference variable of one type cannot be used with an object of the other type.

Extended Hierarchy

extended card hierarchy

The Card hierarchy is extended by adding two new classes:

The class Birthday is the parent for these two new classes. The diagram omits the other two classes, but assume that they are still defined. Each of the new classes would ordinarily inherit the greeting() method from Birthday. But we want to override that method with a specialized method in each of the new classes.

Here is the class definition of Birthday from the previous chapter:

class Birthday extends Card
{
  int age;

  public Birthday ( String r, int years )
  {
    recipient = r;
    age = years;
  }

  public void greeting()
  {
    System.out.println("Dear " + recipient + ",\n");
    System.out.println("Happy " + age + "th Birthday\n\n");
  }
}

Here is a class definition of YouthBirthday:

class    extends   

{
  public   ( String r, int years )
  {
      ( r, years )
  }

  public void greeting()
  {
     ();
    System.out.println("How you have grown!!\n");
  }
}

QUESTION 7:

Fill in the blanks. Don't do this too quickly. Check the requirements and the hierarchy diagram.