EECS2030 Sample Test 3 Version A


Instructions

There is one programming question and six other questions.

Instructions for submitting your programming question solution are given in the programming question section. You may submit as many times as you want; your most recent submission will be the one recorded.

You may leave the lab when you are finished with the test.


Programming question

Implement the Badge class. A skeleton can be found here.

Submit your program using the following command in a terminal (make sure you are in the directory containing your file Badge.java):

submit 2030 test3A Badge.java


Other questions

Question 1

In the declaration of an attribute or field, what does the keyword final denote?
A. That is not inherited by a sub class.
B. That it is a constant.
C. That is belong to a class, not an individual object.



Question 2

Suppose that a class has a copy constructor, but not a default constructor. Which of the following statements is correct?
A. The class does not compile.
B. The compiler adds a default constructor.
C. The compiler does not add a default constructor.



Question 3

A static attribute or field is part of the state of a(n)  



Question 4

The design pattern that ensures that there is at most one instance of a class is known as  



Question 5

The class IP has an attribute named address of type String and implements the multiton design pattern. Two IP objects are the same if they have the same address. Do we have to override the equals method of the Object class? Explain your answer.



Question 6

Consider the following class.

public class Person 
{
   private int age;

   /**
    * Initializes this person with the given age.
    *
    * @param age the age of this person.
    * @pre. age >= 0
    */
   public Person(int age)
   {
      this.age = age;
   }


   /**
    * Increments the age of this person.
    */
   public void increment()
   {
      this.age++;
   }
}
Is
//@ invariant this.age >= 0
a class invariant? Explain your answer.