--:--









Quiz for Access specifiers private, public, protected

Course: C++ Language | Subject: Unit 4 | Topic: Classes and Objects



Logo

Q1: Which access specifier restricts access to class members only within the same class?

Logo

Q2: Which access specifier allows members to be accessed anywhere the object is visible?

Logo

Q3: Which access specifier allows access to derived classes but not outside classes?

Logo

Q4: Can private members be accessed by derived classes?

Logo

Q5: What is the default access specifier for members of a class?

Logo

Q6: What is the default access specifier for members of a struct?

Logo

Q7: Which access specifier can be used to allow specific external functions to access private members?

Logo

Q8: Which specifier restricts member access to only the class and its friends, but not derived classes?

Logo

Q9: Which access specifier allows derived classes and the same class to access the members?

Logo

Q10: Can public members be accessed by derived classes?

Logo

Q11: If a base class has a protected member, how is it accessed in the derived class?

Logo

Q12: Which access specifier should be used to hide implementation details from outside?

Logo

Q13: Which access specifier can increase encapsulation in C++?

Logo

Q14: How do you declare a protected member variable named "count"?

Logo

Q15: What happens if you try to access a private member from outside the class?

Logo

Q16: Are protected members accessible through objects of derived classes?

Logo

Q17: What access level does "friend class" have to another class’s members?

Logo

Q18: Which keyword is used to grant special access to a function or another class?

Logo

Q19: Can private members be accessed using pointers to the class?

Are you ready to start test? Set your time limit