Question: What is the output of the following Java program? class A int k = 1 ; public void System.out.println ( A ) ;

What is the output of the following Java program?
class A
int k=1;
public void System.out.println("A"); }
}
class B extends A{
int k=2;
public void System.out.println("B"); }
}
public class C extends
int k=3;
public void System.out.println("C"); }
public static void main(String[] args){
B b = new C();
System.out.print(b.k);
b.F();
}
Select one:
3B
2C
1A
3C
2B
The correct answer is: 2C
 What is the output of the following Java program? class A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!