Question: Suppose we have the following Java classes: public class Foo {private String mystring; public Foo (String m) {this.mystring = m;} public int length() {return this.mystring.length();}}

 Suppose we have the following Java classes: public class Foo {private

Suppose we have the following Java classes: public class Foo {private String mystring; public Foo (String m) {this.mystring = m;} public int length() {return this.mystring.length();}} public class Bar extends Foo {private String str; public Bar (String s1, String s2) {super (s1); this.str = s2;} public int length() {return this.str.length();} public String geeStr() {return this.str;}} public class FooUtils {public void fooCheck (Foo f) {System.out.println ("It's a Foo!");} public void fooCheck (Bar b) {System.out.println ("It's a Bar!"+b.getStr());}} a. As discussed in class, if we removed the call to super (s1) n the constructor for Bar, this code would not compile. Explain in 1-3 short sentences what the call to super (s1) does in the constructor for Bar and why it is necessary here

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!