Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Given:
Animal.java
public class Animal { String name; public Animal(String name) { this.name = name; } public void speak() {/* Implementation not shown */} }
Dog.java
public class Dog extends Animal { String breed; public Dog(String name, String breed) { this.breed = breed; super(name); } public void speak() {/* Implementation not shown */} }
Main.java
public class Main { public static void main(String[] args) { Dog dog = new Dog("xochi", "chihuahua"); dog.speak(); } }
What will this program do?
Run to completion
Runtime error
Compile error
Infinite loop