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

Question Image
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

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!