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

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!