Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A program currently contains three classes; Employee account, Client account, Ad

ID: 3907129 • Letter: A

Question

A program currently contains three classes; Employee account, Client account, Admin account. Each class contains forty percent of the same data members and eighty percent of the same exact functionality. What action should be taken to remove the redundant data and functionality? O Write a class with those redundant data member then declare a variable of that type in each account class. Write an interface for the functionality then have each account class inherit from it. Write an Account class which combines all the functionality and data of the original account classes, then remove the original account classes. O Write an Account class with that redundant data, then implement it as the parent for the 3 original account classes. Write an interface for the functionality and have the Account class inherit from it Write an Account class with that redundant data and functionality, then implement it as the parent class for the three original account classes

Explanation / Answer

1.

Correct Answer :

d. Write an Account class with that redundant data and functionality then implement it as the parent class for the three original account classes.

The specialization can be done in the derived 3 classes using additional data and functionality.

Other options:

a. A variable of seperate class is also a kind of redundancy. It needs more memory for variable in each class.

b. The specialization or added data and functionality cannot be implemented if a single Account class is used.

c. Interface is needed when same type of functionality needs to implemented in seperate ways. But here for derived account classes, functionality is different. Same functionality is 80% which can be written in base class Account.

2.

Correct Answer:

d. Write an "IsGeode" method which accepts a rock instance,performs the checks, returns a Boolean result.Replace the ninety-nine duplicate checks with checking that single boolean.

All kinds of rocks should be checked for properties similar to Geode.

Other options:

a. is keyword is not present in Java. instanceof() method is used to check if an object belongs to a class.

b. interface is implemented by Geode class only and not other types of rock classes.

c. If a class inherits from Geode class , it contains all the properties of Geode, So a check if it is of type Geode is incorrect.

Do ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote