Question: Consider the following two class definitions: class ClassX { public virtual void f() { WriteLine(f in X); } public void g() { WriteLine(g in X);

Consider the following two class definitions:

class ClassX

{

public virtual void f()

{

WriteLine("f in X");

}

public void g()

{

WriteLine("g in X");

}

}

class ClassY : ClassX

{

public override void f()

{

WriteLine("f in Y");

}

public void h()

{

WriteLine("h in Y");

}

}

==========================================================

This questions uses the same three class definitions as in the last question: class definition code. Also assume the declarations and initializations from the last question (variables x1, x2 and so on).

For each of the following function calls, tell which are syntactically valid and which are not. Also, if the function call is valid, tell what is printed to the console by that function call.

x1.f();

Valid Invalid

Output if valid

x2.f();

Valid Invalid

Output if valid

x1.h();

Valid Invalid

Output if valid

x2.h();

Valid Invalid

Output if valid

y1.f();

Valid Invalid

Output if valid

y2.f();

Valid Invalid

Output if valid

y1.h();

Valid Invalid

Output if valid

y2.h();

Valid Invalid

Output if valid

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!