← Quiz: Java Classes and Objects: all 10 questions
Quiz: Java Classes and Objects · Question 10 of 10
A field is declared protected. Where can it be used?
A field is declared protected. Where can it be used?
- A.Only in the same class
- B.Only in subclasses
- C.Everywhere
- D.In the same package, and in subclasses (even in other packages)
Answer & explanation
Correct answer: In the same package, and in subclasses (even in other packages)
protected adds subclass access on top of package (default) access.
Can you get the rest right without peeking?
Take the timed Quiz: Java Classes and Objects quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →