Start learning 50% faster. Sign in now
This program demonstrates runtime polymorphism in Java through method overriding. When the method display() is called on the object obj, the overridden method in class B is executed. This is because obj is instantiated as new B(), and at runtime, the JVM determines the appropriate method to execute based on the actual type of the object. Thus, even though obj is declared as type A, the overridden display() method in B is executed, producing the output "Class B" . This behavior is a key feature of Java's dynamic method dispatch mechanism. Explanation of Incorrect Options: A) Class A : This would be true if the display() method in class B was not overridden. However, since B overrides A's method, this option is incorrect. C) Compilation Error : The code is syntactically correct, so it compiles without any issues. D) Runtime Error : The program runs successfully, as all method calls are valid and properly resolved at runtime. E) None of the above : This is incorrect, as the correct output is explicitly "Class B" .
From a point "A" on the ground, the angle of elevation to the top of a tower measuring 12 meters in height is 30°. Determine the horizontal distance be...
If sec(2A + B) = 2 and cos(A + B) = (1/√2) , find the value of {sec 2B + tan (A + B) } given that 0o < A, B < 90o
A man is standing at a point 40 meters away from a tower. The angle of elevation of the top of the tower from the point is 45°. After walking 20 meters...
Find the value of sin(θ) if 2sinθ = tanθ, for 0 < θ < 90°.
From a point on the ground, the angle of elevation of the top of a building is 45°. After walking 10 meters towards the building, the angle of elevatio...
Find the simplified value of:
If cos4 B - sin4 B =