Question
Programming language is JAVA: interface I { void f(); } public class A implements I { public void f() { System.out.println(A);} } public class B
Programming language is JAVA:
interface I { void f(); }
public class A implements I {
public void f() {
System.out.println("A");}
}
public class B extends A {
public int n;
public void g() {
System.out.println("B");}
}
public class C extends B {
public void g() {
System.out.println("C");}
}
public class Tester {
static I varI;
public static void main(String[] a)
{
I varJ;
A varA = new A();
B varB = new B();
C varC = new C();
// new code goes here
}
}
Consider various statements to go at the end of main. Maybe the statement(s) involves an assignment, a method call, a class cast. On the e_x_a_m you'll be asked what outcome is produced when we add the statement(s). For example, if we add the statement varB = varA; there would be a compiler error because the assignment is in the wrong direction. Or if we have the statement varB = varC; followed by varB.g() what would the output be?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started