015-003-004

Downcast: Type Conversion

Medium

Problem Description

Downcast: Type Conversion

Learning Objective: Learn type conversion from parent to child class (downcast)

Overview

Downcast converts a parent class type variable to child class type. It only succeeds when the actual object is of the child class.

Specifications

  • Store Dog object in Animal type variable
  • Downcast to Dog type
  • Call Dog-specific method

Output Format

Woof!

Test Cases

※ Output examples follow programming industry standards

Input:
Expected Output:
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining