Solved

Consider the Following Code Snippet

Question 66

Multiple Choice

Consider the following code snippet:
public class SavingsAccount extends BankAccount { ...}
public class CheckingAccount extends BankAccount { ...}
...
SavingsAccount[] savingsAccounts = new SavingsAccount[100]; //Line 1
BankAccount[] bankAccounts = savingsAccounts; //Line 2
BankAccount myAccount = new CheckingAccount() ; //Line 3
bankAccounts[0] = myAccount; //Line 4
Which of the following statements regarding this code is correct?


A) Line 2 will cause a run-time error.
B) Line 4 will cause a compile-time error.
C) Line 4 will cause a run-time error.
D) Line 2 will cause a compile-time error.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions