What's the difference between the following two programs? Program #1: /* intend to let betterFund be a reference to the paulsFund object */ public static void chooseBestAccount(BankAccount better, BankAccount b1, BankAccount b2){ if (b1.getBalance() > b2.getBalance()) better = b1; else better = b2; } public static void main(String[] args){ BankAccount briansFund = new BankAccount(“BrianL”, 10000); BankAccount paulsFund = new BankAccount(“PaulM”, 90000); BankAccount betterFund = null; chooseBestAccount(betterFund, briansFund, paulsFund);
What's the difference between the following two programs?
/* intend to let betterFund be a reference to the paulsFund object */
public static void chooseBestAccount(BankAccount better, BankAccount b1, BankAccount b2){
if (b1.getBalance() > b2.getBalance())
better = b1;
else
better = b2;
}
public static void main(String[] args){
BankAccount briansFund = new BankAccount(“BrianL”, 10000);
BankAccount paulsFund = new BankAccount(“PaulM”, 90000);
BankAccount betterFund = null;
chooseBestAccount(betterFund, briansFund, paulsFund);
}
Program #2:
/* intend to let betterFund be a reference to the paulsFund object */
public static void chooseBestAccount(BankAccount b1, BankAccount b2){
BankAccount better;
if (b1.getBalance() > b2.getBalance())
better = b1;
else
better = b2;
return better;
}
public static void main(String[] args){
BankAccount briansFund [ new BankAccount(“BrianL”, 10000);
BankAccount paulsFund = new BankAccount(“PaulM”, 90000);
BankAccount betterFund = chooseBestAccount(briansFund, paulsFund);
}
Step by step
Solved in 2 steps