Encapsulation in C++ MCQs Exercise II

Ques 1 Encapsulation


How can you access a private member variable of a class from outside the class?

A Private members cannot be accessed from outside the class
B By using a friend function
C By using a member function within the class
D By inheriting from the class

Ques 2 Encapsulation


In C++20, what new feature was introduced to support read-only access to private member variables?

A readonly keyword
B get accessor method
C const keyword
D readonly access specifier

Ques 3 Encapsulation


Which C++20 feature allows you to declare a member function within a class that can be called without creating an object?

A Static member function
B Friend function
C Const member function
D Lambda function