Question: Q.Which statement from s1 to s6 (see below) cause compilation error? Assume the statement that causes compilation is deleted, what is the output when the
Q.Which statement from s1 to s6 (see below) cause compilation error? Assume the statement that causes compilation is deleted, what is the output when the program is executed?
class X{
void f1() { System.out.println("XXX"); }
}
class Y extends X{
void f1() { System.out.println("YYY"); }
}
class Z extends X{
void f1() { System.out.println("ZZZ"); }
}
class Test{
static void g(X a) { a.f1(); }
public static void main(String args[]){
Y y = new Y();
g(y); Object obj = new Y(); obj.f1();
X x = new Z(); x.f1();
// s1 // s2 // s3 // s4 // s5 // s6
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
