Question: Refer to the Java classes below: public class BankAccount { private double myBalance; public BankAccount() { myBalance = 0; } public BankAccount(double Balance) { myBalance

Refer to the Java classes below:

public class BankAccount { private double myBalance; public BankAccount() { myBalance = 0; } public BankAccount(double Balance) { myBalance = balance; } public void deposit (double amount) { myBalance += amount; } public double getBalance() { return myBalance; } } public class SavingsAccount extends BankAccount { private double myInterestRate; public SavingsAccount() { /* implementation not shown */ } public SavingsAccount(double balance, double rate) { /* implementation not shown */ } public void addInterest() { /* implementation not shown */ } }

Of the methods shown, how many different nonconstructor methods can be invoked by a SavingsAccount Object?

Select one:

a. 1

b. 2

c. 3

d. 4

2.

Assume that the following Prolog program has been consulted.

a(B,B).

Determine the output of the following query and enter in the answer blank.

?- a(1,B), a(B,C), (C,D), a(D,10).

Answer:

3.

Which of the following represents the best reason to use tail recursion?

Select one:

a. the recursive call can be optimized away by a modern compiler

b. It makes recursive functions more efficient than loops

c. It eliminates the need for stack frames

d. It makes the code simpler

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!