Kotlinlearncs.online LogoJava
Return to List

Solve: Math Course Inheritance

Created By: Pranav Narayanan
/ Version: 2024.10.0

Write a public class MathCourse which inherits from the existing class Course:

public class Course {
 private String code;
 private String title;
 public Course(String code, String title) {
   this.code = code;
   this.title = title;
 }
 //getters omitted
}

MathCourse should have an additional String field area, which is the branch of math that course pertains to. Provide only a getter for area following the standard naming convention. You should define a MathCourse constructor that accepts parameters for the code, title, and area in that order. Reject null values for area.

MathCourse should also override toString() so that it returns a String of the format: "(code): (title) is in the (area) branch of math."

Related Lessons

Stuck? You may find these lessons helpful:

Report a Problem

Attribution must link to this page: https://www.learncs.online/solve/java/math-course-inheritance/[email protected]