What is the difference(s) between a public and private instance variable? Privat
ID: 3799191 • Letter: W
Question
What is the difference(s) between a public and private instance variable? Private instance variables cannot be directly read while public instances variables can be directly read and set. Private instance variables cannot be directly read or set while public instances variables can be directly read and set. Private instance variables cannot be directly set while public instances variables can be directly read and set. Private instance variables cannot be directly set while public instances variables can be directly set. Private instance variables cannot be directly read or set while public instances variables can be directly set but not directly read.Explanation / Answer
-Private instance variables cannot be directly set while public instances variables can be directly read or set.
Because private variables are only accessed within class and cannot be modified directly ouside the class. Whereas a public instance variable can be read and set(or modified) directly. If we want to control an insatnce variable then we declare it as private.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.