The superclass, EducationalInstitution, contains: an int instance variable, duration, indicating the standard number of years spent at the institution A constructor that accepts an int which is used to initialize the duration instance variable a method graduationRequirements that returns a String. The (default) behavior of graduationRequirements is to return a String stating “d years of study”, where d is the value of the duration instance variable Write a class definition for the subclass LawSchool that contains: a (default ) constructor that invokes the superclass constructor with the value 3 (law school is typically a three year program). a (overridden) method graduationRequirements that returns the string “3 years of study and passing the bar”. You MUST invoke the graduationRequirements method of the superclass in this method (to obtain the first portion of the resulting string).

5
The superclass, EducationalInstitution, contains: an int instance variable, duration, indicating the standard number of years spent at the institution A constructor that accepts an int which is used to initialize the duration instance variable a method graduationRequirements that returns a String. The (default) behavior of graduationRequirements is to return a String stating “d years of study”, where d is the value of the duration instance variable Write a class definition for the subclass LawSchool that contains: a (default ) constructor that invokes the superclass constructor with the value 3 (law school is typically a three year program). a (overridden) method graduationRequirements that returns the string “3 years of study and passing the bar”. You MUST invoke the graduationRequirements method of the superclass in this method (to obtain the first portion of the resulting string).

LANGUAGE: JAVA

CHALLENGE:

The superclass, EducationalInstitution, contains:
an int instance variable, duration, indicating the standard number of years spent at the institution
A constructor that accepts an int which is used to initialize the duration instance variable
a method graduationRequirements that returns a String. The (default) behavior of graduationRequirements is to return a String stating “d years of study”, where d is the value of the duration instance variable
Write a class definition for the subclass LawSchool that contains:
a (default ) constructor that invokes the superclass constructor with the value 3 (law school is typically a three year program).
a (overridden) method graduationRequirements that returns the string “3 years of study and passing the bar”. You MUST invoke the graduationRequirements method of the superclass in this method (to obtain the first portion of the resulting string).

SOLUTION:


public class LawSchool extends EducationalInstitution {
   public LawSchool() {
      super(3);
   }

   public String graduationRequirements() {
      String x = super.graduationRequirements() + " and passing the bar";
      return x;
   }
}

5 comments

  • Kevin says:

    public class LawSchool extends EducationalInstitution {
    public LawSchool() {
    super(3);
    }

    public String graduationRequirements() {
    return super.graduationRequirements() + ” and passing the bar”;
    }
    }

  • Basil says:

    public class LawSchool extends EducationalInstitution {
    public LawSchool()
    {
    super(3);
    }
    public String graduationRequirements()
    {
    String x = super.graduationRequirements() + ” and passing the bar”;
    return x;
    }
    }

  • That guy says:

    “You are not returning the proper string for graduationRequirnments”

  • KenM66 says:

    The quotation marks are off on the above comments.
    It’s accutally this…

    public class LawSchool extends EducationalInstitution {
    public LawSchool()
    {
    super(3);
    }
    public String graduationRequirements()
    {
    String x = super.graduationRequirements() + ” and passing the bar”;
    return x;
    }
    }

Add comment