Which Among The Following Is True For The Code Given Belowp Pre #241
Which among the following is true for the code given below?</p> <pre><code class="language-cpp"> class A { int marks; public : disp() { cout<<marks; } } class B: protected A { char name[20]; } A a; a.disp(); 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: Public Access Specifier - Quiz No.1.
Which among the following is true for the code given below?
class A { int marks; public : disp() { cout<<marks; } } class B: protected A { char name[20]; } A a; a.disp(); B b; b.disp();
Only object of class A can access disp() function
Only object of class B can access disp() function
Both instances can access disp() function
Accessing disp() outside class is not possible