CSCI A201/A597

Takehome Quiz Three

Second Summer 2000


Third set of questions due Monday July 3, on paper. Answers will be posted Tuesday at noon.

Questions:

  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); 
    and
    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 define object variables that are initialized with the required objects.

  9. Find the errors in the following statements:
    Rectangle r = (5, 10, 15, 20); 
    
    double x = BankAccount(10000).getBalance(); 
    
    BankAccount b;
    b.deposit(10000); 
    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.deposit(5000);
    b.withdraw(b.getBalance() / 2); 

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

  13. What is the this reference?

Last updated: June 25, 2000 by Adrian German for A201