Question: class Parent{ public int stuff() { return 1; } } class ChildOne extends Parent { @Override public int stuff() { return 2; } } class

 class Parent{ public int stuff() { return 1; } } class

class Parent{

public int stuff() {

return 1;

}

}

class ChildOne extends Parent {

@Override

public int stuff() {

return 2;

}

}

class ChildTwo extends Parent {

@Override

public int stuff() {

return 3;

}

}

class MainClass {

public static void Main (string[] args) {

Parent var1=new Parent();

ChildOne var2=new ChildOne();

ChildTwo var3=new ChildTwo();

Parent var4=new ChildOne();

Parent var5=new ChildTwo();

int sum=var1.stuff() + var2.stuff() + var3.stuff() + var4.stuff() + var5.stuff();

System.out.println ("Sum is "+sum);

}

}

What is the output of the following code

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!