014-003-010
Calling Parent Constructor with super()
Easy
Problem Description
Calling Parent Constructor with super()
In this problem: You will create a program where a Student class inherits from a Person class and uses super() to explicitly call the parent constructor.
Learning Objective: Understand the basics of calling a parent class constructor using the super() keyword
Overview
The Person class has a constructor that accepts a name. The Student class extends Person and calls super(name) in its constructor to initialize the parent class. It also manages a student ID on its own.
Specifications
Personclass:namefield,Person(String name)constructor,getName()methodStudentclass: extendsPerson,studentIdfield,Student(String name, String studentId)constructor- Call
super(name)inside theStudentconstructor - Create a Student instance in
Mainand print the information
Output Format
Name: Tanaka
Student ID: S001
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up