Java Programming - Encapsulation Activity
Java Programming - Encapsulation Activity
Don’t change any code inside your Main class from scenario one,
and copy it for scenario two.
End-of-Activity Questions:
1. What was your observation in Scenario 1 (using the public access modifier)?
Explain how the name attribute was accessed and modified. What
output did you observe when you ran the program?
3. In your own words, what is the purpose of a private access modifier in Java?
Explain why it is important to use the private modifier for attributes in
object-oriented programming and how it helps with controlling access
to the data.
A Google Forms link has been sent to our group chat as a platform for you to
submit your answers. Please use the form to respond to the questions about
the code observations and the purpose of the private access modifier.