What two changes, made independently, will enable the code to compile?

Given:

public abstract class Account {

abstract void deposit (double amt);

public abstract Boolean withdraw (double amt);

}

public class CheckingAccount extends Account {

}

What two changes, made independently, will enable the code to compile?

Given:

public abstract class Account {

abstract void deposit (double amt);

public abstract Boolean withdraw (double amt);

}

public class CheckingAccount extends Account {

}

What two changes, made independently, will enable the code to compile?

A.
Change the signature of Account to: public class Account.

B.
Change the signature of CheckingAccount to: public abstract CheckingAccount

C.
Implement private methods for deposit and withdraw in CheckingAccount.

D.
Implement public methods for deposit and withdraw in CheckingAccount.

E.
Change Signature of checkingAccount to: CheckingAccount implements Account.

F.
Make Account an interface.

Explanation:
B:Unlike interfaces, abstract classes can contain fields that are not static and final, and they can contain implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial implementation, leaving it to subclasses to complete the implementation.

F:If an abstract class contains only abstract method declarations, it should be declared as an interface instead.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Kamil

Kamil

B, D

manish purohit

manish purohit

B & D are correct options