Question
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);
}
}
a.
B salary is: 4000.0
Bonus of B is: 10000
b.
B salary is 10000
Bonus of B is: 4000.0
c.
Compile time error
d.
Runtime error
Posted under Object Oriented Programming
Bonus of B is: 10000
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. Output of following program?
Similar Questions
Discover Related MCQs
Q. Single level inheritance will be best for___________
View solution
Q. Which constructor will be called first from the classes involved in single inheritance from object of derived class?
View solution
Q. If base class contains 2 nested classes, will it be possible to implement single level inheritance?
View solution
Q. Which among the following best defines multilevel inheritance?
View solution
Q. If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class constructor will be called first if the object of E or D is created?
View solution
Q. If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroyed.
View solution
Q. Which Class is having highest degree of abstraction in multilevel inheritance of 5 levels?
View solution
Q. If all the classes use private inheritance in multilevel inheritance then ______________
View solution
Q. Multilevel inheritance allows _________________ in the program.
View solution
Q. What is minimum number of levels for a implementing multilevel inheritance?
View solution
Q. In multilevel inheritance one class inherits _______________
View solution
Q. All the classes must have all the members declared private to implement multilevel inheritance.
View solution
Q. Can abstract classes be used in multilevel inheritance?
View solution
Q. How many abstract classes can be used in multilevel inheritance?
View solution
Q. If all the classes used parameterized constructors and no default constructor then, ___________
View solution
Q. In multilevel inheritance, which is the most significant feature of OOP used?
View solution
Q. Is it compulsory for all the classes in multilevel inheritance to have constructors defined explicitly if only last derived class object is created?
View solution
Q. Multiple inheritance is ____________________
View solution
Q. Which problem arises due to multiple inheritance, if hierarchical inheritance is used previously for its base classes?
View solution
Q. How many classes should a program contain to implement the multiple inheritance?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!