Spring Semester 2002

Lab Notes Four: The warm-ups.


  1. Explain the difference between an object and a class.

  2. Give the Java code for an

  3. Explain the differences between an instance variable and a local (or method) variable.

  4. Explain the difference between
    new BankAccount(5000); 
    BankAccount b;

  5. What are the construction parameters for a BankAccount object?

  6. What is default construction?

  7. Give Java code to construct the following objects:

    Write just objects, not object variables.

  8. Repeat the preceding exercise, but now

  9. Find the errors in the following statements:
    Rectangle r = (5, 10, 15, 20); 
    double x = BankAccount(10000).getBalance(); 
    BankAccount b;
    b = new BankAccount(10000);
    b.addCoins(new Coin(0.25, "quarters")); 
    Purse p = null; 
    p.addCoins(new Coin(0.25, "quarters")); 
    Purse p = new Purse(); 
    p.addCoins(new Coin()); 

  10. Describe all constructors of the BankAccount class. List all methods that can be used to change a BankAccount object. List all methods that don't change the BankAccount object.

  11. What is the value of b after the following operations?
    BankAccount b = new BankAccount(10); 
    b.withdraw(b.getBalance() / 2); 

  12. If b1 and b2 store objects of class BankAccount, consider the following instructions.
    Are the balances of b1 and b2 now identical? Explain.

  13. What is the this reference?

These are all questions from the book.

Last updated: Jan 28, 2002 by Adrian German for A201