Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Unit 9 Assignment #3

Written Exercises:
TRUE/FALSE

7.9 a polymorphic reference variable can refer to different types of objects at different
times.

True

Coding Exercises: Do in ​Unit9Ex ​BlueJ project


Updating ​BankAccount​ and its Subclasses
Add a ​TimeDepositAccount ​class to the bank account hierarchy. The time deposit
account is just like a savings account, but you promise to leave the money in the
account for a particular number of months, and there is a penalty for early withdrawal.

Construct the account with the interest rate of the account, the number of months to
maturity (number of months the money must remain in the account before it can be
withdrawn), and the penalty that will be charged (amount of money).

In the ​endOfMonth ​method, decrement the count of months. If the count is positive
during a withdrawal, charge the withdrawal penalty. There is no penalty for depositing
money into the account.

Tester ​HERE

MULTIPLE CHOICE Question #1


a.
MULTIPLE CHOICE Question #2

b.
MULTIPLE CHOICE Question #3

d.

SHORT ANSWER Question 1:


The following won’t compile. What is the mistake?

A class can’t inherit from 2 parent classes.

SHORT ANSWER Question 2:


What will be the output when the ​main​ method inside ​MainClass​ is executed?
Class A Constructor
Class B Constructor
Class C constructor

SHORT ANSWER Question 3:


What is the error in the code below?

There is no default constructor for x, and the constructor there is cannot be called
because the arguments were not specified in y.

You might also like