Declarations and Access Control

Q1: Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

A private

B final

C protected

D volatile

E static

ANS:C - private

The private access modifier limits access to members of the same class. Option A, B, D, and E are wrong because protected are the wrong access modifiers, and finalstatic, and volatile are modifiers but not access modifiers.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.