Limited access

Upgrade to access all content for this subject

You are a programmer working on a large project. You are asked to create a class that will be used by several other classes and even used in code created by programmers at other companies. Your class is fairly straightforward; every instance of the class needs to keep track of a quantity and dollar amount that can be changed by other programs.

Which of the following choices BEST describes how you should define the data and methods in this class?

A

Make the data private and define public accessor methods to retrieve the data.

B

Make the data private and define public accessor methods to retrieve the data and public modifier methods to change the data.

C

Make the data public so it can be modified directly by other classes.

D

Make the data public and define public accessor methods to retrieve the data and public modifier methods to change the data.

E

Make the data public and define public accessor methods to retrieve the data.

Select an assignment template