Members of a class may have their access specified as public or private but not as protected. O True O False
Added by Tina C.
Close
Step 1
Class members can be declared as public or private, but not protected. Show more…
Show all steps
Your feedback will help us improve your experience
Aditya Sood and 51 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
If you want to keep classes that instantiate objects of a class from changing their data members, but enable derived classes to change base class data members, the data members in the base class should be defined with a _____________ access modifier. a. private b. public c. internal d. static e. protected
Mark the following statements as true or false. a. The member variables of a class must be of the same type. (1) b. The member functions of a class must be public. (2) c. A class can have more than one constructor. (5) d. A class can have more than one destructor. (5) e. Both constructors and destructors can have parameters. (5)
Consider the following code: public class MyClass { private int secret; public int getSecret() { return secret; } } Is the instance variable secret really private, meaning that it cannot be changed by client code? Yes, because it is private Yes, because it is private and non-static No, because getSecret returns a reference to secret, which allows direct access to the instance variable No, because getSecret returns the value of secret, which can be changed by the client No, because MyClass is a public class, and so its instance variables are all accessible by outside classes
Luke H.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD