X774: Create Child Class

For this question, assume the following implementation of the class Person and the following UML diagram

Person Class Implementation

public class Person{
        private String name;
        private int age;
        private double heightInCM;

        public Person (String na, int ag, double he) {
            name  = na;
            age = ag;
            heightInCM = he;
        }

        public String getName() {
            return name;
        }
        public int getAge() {
            return age;
        }
        public double getHeightInCM() {
            return heightInCM;
        }

        public String toString() {
            return getName()
                + ":\n Age: " + getAge()
                + "\n Height: " + getHeightInCM() + " cm";
        }
    }

This UML diagram shows two Java classes: Person, with attributes name, age, and heightInCM, and Student, which inherits from Person and adds studentID and school. Both classes have constructors and getter methods for accessing their respective attributes.

Question

Using the UML Diagram displayed here, create the Student class.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.