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

What should you do with data fields of your class that represent attributes of a

ID: 3815584 • Letter: W

Question

What should you do with data fields of your class that represent attributes of a real world object ?

Make them all public always

B - Always make them private, provide accessors and/or mutators depending on Use cases that access those objects

Just never make them public and never provided accessors and mutators ever.

Make them private, provide accessors and/or mutators depending on need, BUT move them to public if needed

A -

Make them all public always

B - Always make them private, provide accessors and/or mutators depending on Use cases that access those objects

   C -

Just never make them public and never provided accessors and mutators ever.

     D-  

Make them private, provide accessors and/or mutators depending on need, BUT move them to public if needed

Explanation / Answer

Answer:

B)Always make them private, provide accessors and/or mutators depending on Use cases that access those objects

Explanation:As attributes are real world object we should always provide setters and getters for that as they are designed for that only and we should not allow to access the attributes directly hence make them private.

Note:Please do ask in case of any doubt,Thanks.

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