Java Reference
In-Depth Information
addInterest method should be provided to add the earned interest to
the account. This method should have no parameters since the interest rate
is already known. It should have no return value since the new balance can
be obtained by calling getBalance . Give the public interface for this
class.
΢΢Exercise R3.10 What are the accessors and mutators of the
CashRegister class?
΢ Exercise R3.11 Explain the difference between a local variable and a
parameter variable.
΢ Exercise R3.12 Explain the difference between an instance field and a
local variable.
΢΢G Exercise R3.13 Suppose you want to write a program to show a
suburban scene, with several cars and houses. Which classes do you
need?
΢΢΢G Exercise R3.14 Explain why the calls to the getWidth and
getHeight methods in the CarComponent class have no explicit
parameter.
΢΢G Exercise R3.15 How would you modify the Car class in order to show
cars of varying sizes?
Additional review exercises are available in Wiley PLUS.
PROGRAMMING EXERCISES
΢ Exercise P3.1. Write a BankAccountTester class whose main
method constructs a bank account, deposits $1,000, withdraws $500,
withdraws another $400, and then prints the remaining balance. Also print
the expected result.
΢ Exercise P3.2. Add a method
public void addInterest(double rate)
Search WWH ::




Custom Search