Which Among The Following Is True For The Given Code Belowp Pre #231
Which among the following is true for the given code below?</p> <pre><code class="language-cpp"> class A { protected : int marks; public : A() { marks=100; } disp() { cout<<”marks=”<<marks; } }; class B: protected A { }; B b; b.disp(); </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 OOps Access Specifiers - OOPs MCQ: Protected Access Specifier - Quiz No.1.
Which among the following is true for the given code below?
class A { protected : int marks; public : A() { marks=100; } disp() { cout<<”marks=”<<marks; } }; class B: protected A { }; B b; b.disp();
Object b can’t access disp() function
Object b can access disp() function inside its body
Object b can’t access members of class A
Program runs fine