01 public class Account 02 03 private double balance 04 pri
01 public class Account
02 {
03 private double balance;
04 private String name;
05 private long acctNum;
06
07 public Account(double initBal, String owner, long number)
08 {
09 balance = initBal;
10 name = owner;
11 acctNum = number;
12 }
13
14 public void withdraw(double amtToTake)
15 {
16 balance -= amtToTake;
17 }
18
19 public void deposit(double amtToAdd)
20 {
21 balance += amtToAdd;
22 }
23
24 public double getBalance()
25 {
26 return balance;
27 }
28
29 public String toString()
30 {
31 String s = \"Acct:\" + acctNum;
32 s += \" owner:\" + name;
33 s += \" Bal:$\" + balance;
34 return s;
35 }
36}
what are the mutators in the program? the accessors? the local variables? the instant variables? What are the parameters? Which of the following contain comprise the state of an Account object? Which of the following provide the behavior of an Account object? Which of the following provide the behavior of an Account object? What are the members What Are the formal parameters
Solution
what are the mutators in the program? deposit() and withdraw() are the mutator here.
the accessors? getBalance() is the accessor in the class.
the local variables? initBal, owner, number, amtToTake, amtToAdd are all the local variables here.
the instant variables? The instance variables are: balance, name, and acctNum, s.
What are the parameters? The parameters for constructor are: initBal, owner, and number. The parameter for withdraw() is amtToTake. The parameter for deposit() is amtToAdd.
Which of the following contain comprise the state of an Account object?
Which of the following provide the behavior of an Account object?
Which of the following provide the behavior of an Account object?
What are the members. The member variables are: balance, name, and acctNum. The member functions are: Account(), withdraw(), deposit(), getBalance(), toString().
What Are the formal parameters. The formal parameters are not known.
01 public class Account
02 {
03 private double balance;
04 private String name;
05 private long acctNum;
06
07 public Account(double initBal, String owner, long number)
08 {
09 balance = initBal;
10 name = owner;
11 acctNum = number;
12 }
13
14 public void withdraw(double amtToTake)
15 {
16 balance -= amtToTake;
17 }
18
19 public void deposit(double amtToAdd)
20 {
21 balance += amtToAdd;
22 }
23
24 public double getBalance()
25 {
26 return balance;
27 }
28
29 public String toString()
30 {
31 String s = \"Acct:\" + acctNum;
32 s += \" owner:\" + name;
33 s += \" Bal:$\" + balance;
34 return s;
35 }
36}


