014-003-004

Explicit Super Constructor Call

Medium

Problem Description

Explicit Super constructor Call

In this problem, you will create a program that defines an Animal parent class and a Dog subclass whose constructor explicitly calls super(name) to initialize the parent, then reads a name and breed from standard input and displays the Dog object's information to standard output.

Learning Objective: Understand how to explicitly call parent class constructor using super()

Overview

Create parent class Animal and child class Dog, and explicitly call Animal's constructor from Dog's constructor.

Specifications

  • Animal class: name field and constructor
  • Dog class: breed field and constructor using super()
  • Read name and breed from standard input, create Dog object, and output information

Input Format

name
breed

Output Format

Name: name
Breed: breed

Example

Input:

Pochi
Shiba

Output:

Name: Pochi
Breed: Shiba

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