What Is The Output Of The Following Programp Pre Langcpp #746
What is the output of the following program?</p> <pre><code class="language-cpp"> class A { float sal=40000; } class B extends A { int salBonus=10000; public static void main(String args[]) { B p=new B(); System.out.println("B salary is:"+p.sal); System.out.println("Bonus of B is:"+p.bonus); } } </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 Inheritance & its Types - OOPs MCQ: Single Level Inheritance - Quiz No.2.
What is the output of the following program?
class A { float sal=40000; } class B extends A { int salBonus=10000; public static void main(String args[]) { B p=new B(); System.out.println("B salary is:"+p.sal); System.out.println("Bonus of B is:"+p.bonus); } }
B salary is: 4000.0 Bonus of B is: 10000B salary is 10000 Bonus of B is: 4000.0
Compile time error
Runtime error