EECS2030 Test 4


Instructions

There is one programming question and three other questions.


Programming question

Implement the WordPuzzle class. A skeleton can be found here. The API can be found here. A jar with the Lock class can be found here.


Other questions

Question 1

Are non-static attributes of the super class part of the state of instances of the sub class? Select the best answer.
A. Yes.
B. No.
C. Only if they are private.
D. Only if they are public.



Question 2

Another name for the inheritance relation is the     relation.



Question 3

Consider the following classes.

public class CreditCard
{
   private double balance;

   /**
    * Tests whether the balance of this card is positive.
    *
    * @return true if the balance of this card is positive, false otherwise.
    */
   public boolean positive()
   {
      return this.balance > 0;
   }
}

public class RewardCard extends CreditCard
{
   private int points;

   /**
    * Tests whether the balance or the points balance of this card is positive.
    *
    * @return true if the balance or the points balance of this card is positive, false otherwise.
    */
   public boolean positive()
   {
      return super.positive() || this.points > 0;
   }
}
Point out what is wrong in the above code. ("Use this.getBalance() instead of this.balance" is not the answer.)