What Will Be The Output Of The Following Code All Header Files #230
What will be the output of the following code (all header files and required things are included)?</p> <pre><code class="language-cpp"> class A { int marks; protected : A(int x) { marks=x; } public : A() { marks=100; } } class B { A a; A b=100; }; main() { A a, b=100; B c; } </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.
What will be the output of the following code (all header files and required things are included)?
class A { int marks; protected : A(int x) { marks=x; } public : A() { marks=100; } } class B { A a; A b=100; }; main() { A a, b=100; B c; }
Program runs fine
Program gives runtime error
Program gives compile time error
Program gives logical error