Consider the following Java program. What is the output of the program? class A { int x = 10; } class B extends A { int x = 20; public static void main(String[] args) { A obj = new B(); System.out.print(obj.x); } }Single choice

A
A. Compilation error
B
B. 10
C
C. Runtime error
D
D. 20
Log in for full answers
We've collected over 50,000 authentic original questions and detailed explanations from around the globe. Log in now and get instant access to the answers!
Similar Questions
Consider the following Java program. What is the output of the program?
Consider the following Java program. What is the output of the program?
Is the following statement true or false? In the products of methylation-hydrolysis, every -OH group corresponds to the position of a glycosidic bond in the starting polysaccharide.
Which of the follwoing structures represents amylopectin?
More Practical Tools for Students Powered by AI Study Helper
Making Your Study Simpler
Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!