Edit this code so the class Beagle is a subclass of the Dog class. When you run the code it should print "woof!" and then "arf arf". Run Online (1) Abdulrahamn Aljabali Dog.java 1 public class Dog 2 { 3 public void speak() 4 { 5 System.out.println("woof!"); 6 } 7 8 public static void main(String[] args) 9 { 10 Dog d = new Dog(); 11 d.speak(); 12 Dog b = new Beagle(); 13 b.speak(); 14 } 15 } 16 17 class Beagle 18 { 19 public void speak() 20 { 21 System.out.println("arf arf"); Reset to Template
Added by Melinda B.
Close
Step 1
The code defines a class called "Dog" with a method called "speak". The "speak" method simply prints "woof!" to the console. Show more…
Show all steps
Your feedback will help us improve your experience
Anecia Mcmurrin-Bala and 54 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
In this exercise, we've started to declare some variables, but we don't know the answers to the questions. You should fill in the rest of the lines to make them correct. String myName = "Karel the Dog"; int luckyNumber = 11; double ... (missing information) boolean ... (missing information) Edit the code so that the output of running the program is: Karel the Dog 11 75.3 true
Shelayah R.
Rosemary C.
Compiling and Executing a Java Program public class Programming { public static void main(String[] args) { System.out.println("I am learning how to program."); } } Summary In this lab, you compile and execute a prewritten Java program. Instructions 1. Execute the program. There should be no syntax errors. 2. Modify the program so it displays "I'm learning how to program in Java.". Execute the program. 3. Modify the Programming class so it prints two lines of output. Change the class name to Awesome. In Java, the file name must match the class name, so change the file name to Awesome.java. Add a second output statement that displays "That's awesome!". Execute the program.
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD