public void makeNoise() { System.out.println("talk"); }//end method makeNoise }//end class Animal public class Dog extends Animal { public void makeNoise() { System.out.println("Bark"); }//end method makeNoise }//end class Dog What would the output of the following be? Explain your answer. Animal animal = new Animal(); animal.makeNoise(); Dog dog = new Dog(); dog.makeNoise(); Animal animaldog = new Dog(); animaldog.makeNoise();
Q: Use Java Programming Language Loan Account Class: Create class LoanAccount. Use a static variable…
A: The java code is given below.
Q: Your task is to implement the following Product class. The description of the class is as follows:…
A: In this question we have to write the JAVA code with the given implementation list. Where, we have…
Q: The following code is valid in Java: public abstract class Shape ( private String name; public…
A: The given code in Java will not work. Therefore, the correct is False.
Q: Create a method "public void giveRaise(int percentage)" in the Employee class. This method should…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: What is output? public abstract class Vehicle {. public abstract void move(int miles); public void…
A: Your answer is given below with an output and explanation.
Q: Q3: (Practical Question) Create a C++ class and name it Vehicle. The class Vehicle has two constant…
A: Answer
Q: (java programing) Define a student class. A student has the following attributes: Firstname: the…
A: import java.io.*; import java.util.*;class student{ string firstname,lastname,gender,status;…
Q: Create a Calculator class that has following methods: sum, multiply, divide, modulus, sin, cos, tan…
A: GIVEN: Using java create class calculator.
Q: (Java) 7.2 Code: Look at the following Person.java class code: class Person{ public String name;…
A: The toString() method is a method in java that is used to print or output the values of an object or…
Q: Java Problem. compile and run the code below: /** A class to test the Door class. */ public…
A: Class definition: A class is a user-defined data type that contains the data members and methods.…
Q: Implement the following classes in Java. Date class which has day(int), month(int) and year(int)…
A: Total 5 classes needs to be maid one each for date, time, datetime, pizzaorder and test class. Date…
Q: public class Ice extends Fire { public void method1() { System.out.print("Ice 1 "); public class…
A: Output of the given program is given below:-
Q: The class RoachPopulation simulates the growth of a roach population.The constructor takes the size…
A: Program code #1:
Q: Rectangle.java /** * Models a rectangle with a width and length. */ 4 public class Rectangle { //…
A: The class Rectangle has following definition: Data members (private): length of type double width…
Q: public class Appliance { public int getVoltage() { return 10; } Appliance.java public interface…
A:
Q: at has following methods: sum, multiply, divide , modulus , sin , cos , tan
A: JAVA code Create a Calculator class that has following methods: sum, multiply, divide , modulus ,…
Q: Modify the Date class below by adding a new method called nextDay() that increments the Date by 1…
A: import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar; //Date…
Q: the blank in the main method. public class Min { //define your static method here } Write a static…
A: In this question we have to complete the given method in the Java code. For the method where it will…
Q: Consider the following three Java classes: public abstract class Toy { public void makeNoise() {…
A: doll.makeNoise(); doll is an instance of Doll class and it invokes makeNoise() method in Doll…
Q: Consider a class RatingScore that represents a numeric rating for something such as a movie. Its…
A: According to the information given:- We have to take input rating from the user about movie. will…
Q: eSenior = 3; } Answer these questions according to the UML class schema and the code given above.…
A: [JAVA] public class FlightRules {public final static int minHostessCount = 2;public final static int…
Q: Please attach screenshots of code and output screenshots are must needed
A: print("### Question 3: Class and Methods") import math class Circle: ''' A class to represent a…
Q: # Coding - Simulate a robot Write a program that simulates the movements of a robot. The robot can…
A: Let G - advance L- turn left R- Turn right
Q: Assume the class Student implements the Speaker interface from the textbook. Recall that this…
A: HERE IS COMPLETE CODE WITH OUTPUT
Q: Design a class that holds the following personal data: name, address, age, and phone number. Write…
A: class Person {// private data members private String name, address; private int age,…
Q: * Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac…
A: Given that:
Q: Write the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should…
A: Create a class Circle and define it's instance variable as private type and just declare default…
Q: Complete the partial declaration of Class Car: public class Car { // declare three…
A: this keyword takes value from current object of instance variables. A setter method is always of…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Assume the Book class is defined as follows: public class Book{ enum Type type…
A: The Book class is defined as follows: public class Book{ enum Type type {FICTION,NON_FICTION};…
Q: 2. Given the Baby class below: public Class Baby { String name; int birthWeight; } Write an equals…
A: class Baby { public : string name; int birthWeight; };
Q: WRITE THE OUTPUTS OF THE FOLLOWING!!! A.) public class MyClass { static void myMethod() {…
A: JAVA supports the properties of encapsulation and data hiding through the creation of user-defined…
Q: UML for the following Code: public class ProductOrder { private int numBook = 0; private…
A: Answer: We have written UML diagram for given following code
Q: In java language on netbeans design a console application that will print the game sales for a…
A: Here I have created the class Games that implements the interface iGames. In this class, I have…
Q: Problem Description: Write a class Battery that models a rechargeable battery. A battery has a…
A: The program is written in java class Battery{ double capacity; double original_capacity;…
Q: Design a class Parallelogram that contains two private data members: - double length, - double…
A: // C++ program to demonstrate implementation // of Inheritance #include <bits/stdc++.h> using…
Q: Support computing sales tax in the CashRegister class. The tax rate should be supplied when…
A: Note: you have not provided CashRegisterTester.java class file. so, we cannot provide compiled code…
Q: tumLeft and turn Right methods that change the direction of the robot but not the location move…
A: public class Robot{ //declaring instance variables private String name; private int xPos; private…
Q: How many methods and constructors do objects of type Middle have? public class Left{ public Left x;…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write the definition of a classTelephone. The class has no constructors and one static method…
A: In this java code we have to define the class Telephone where it will have one static method and…
Q: IN JAVA PLEASE Child Class: Vegetable Write a child class called Vegetable. A vegetable is described…
A: We need to write a Java class for the given scenario.
Q: Find the error(s) in the following class definition: public class TestClass { private int value1;…
A: answer along with screenshots are given below
Q: WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THE PROGRAM : JAVA
A: Output: Item Number:112Name: BookQuantity: 3Price: 125.98Total Cost: 0.0Item Number:101Name:…
Q: FOR JAVA Part I Create a Company class that has at least three properties. Part II Write…
A: we write java code: class Company { int company_id,turnover; String name,address,department,email;…
Q: GIVEN //BookMain.java //This is the client code of Book class public class BookMain{ public static…
A: Note: since your question contain multiple question (having implementation of books and library main…
Q: 1/ Write a BankAccountTester class whose main method constructs a bank account, deposits $1,000,…
A: 1. BankAccountTester.java public class BankAccountTester { public static void main(String…
Q: What does it mean when a method is overloaded?
A: Method overloading Method overloading is a process used in object oriented programming. Polymorphism…
Q: Write a java program to create a class Rectangle. The class has attributes Length and Width. It…
A: Below is the java program with comments and output snapshots.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Consider the following three Java classes: public abstract class Toy {public void makeNoise() { System.out.println("DEFAULT SOUND"); }} public class Doll extends Toy {public void makeNoise() { System.out.println("Mama!"); }}public class ToyRobot extends Toy {private int volume; public ToyRobot() { this.volume = 5; } public void makeNoise() { System.out.println("BEEP"); } public int getVolume() { return volume; } public void setVolume(int volume) { this.volume = volume; }} Given these classes, determine what will be printed when each of the code snippets below are copied into the following main method at the indicated location. public static void main(String[] args) { Toy toy; Doll doll; ToyRobot robot1; ToyRobot robot2; doll = new Doll(); robot1 = new ToyRobot(); robot2 = robot1; toy = robot1; // INSERT CODE HERE. } A) doll.makeNoise(); ["", "", "", ""] B) toy.makeNoise(); ["", "", "", ""] C)…Java Programming problem Create a checking account class with three attributes: account number, owner’s name, and balance. Create constructor, getters and setters. If one is to set the initial balance of an account as a negative value in a setter or a constructor, remind the user about the error and set it as 0. Create a CheckingAccountDemo class, and create a main method in which Ask for the name, account number, and initial balance for one account from the keyboard input. With these input values as arguments in a call to the constructor, create a CheckingAccount object. Print the summary of this account that includes information on the name, account number, and balance by calling the getters.Type a Java method constructor for the "book" Class, which takes values as parameters for all of these attributes.The" book " Class has the following properties: title (string), author (string), year (int), pages (int).
- 1/ Write a BankAccountTester class whose main method constructs a bank account, deposits $1,000, withdraws $500, withdraws another $400, and then prints the remaining balance. Also print the expected result 2/ Implement a class Employee. An employee has a name (a string) and a salary (a double). Provide a constructor with two arguments public Employee(String employeeName, double currentSalary) and methods public String getName() public double getSalary() public void raiseSalary(double byPercent) These methods return the name and salary, and raise the employee's salary by a certain percentage. Sample usage: Employee harry = new Employee("Hacker, Harry", 50000); harry.raiseSalary(10); // Harry gets a 10 percent raise Supply an EmployeeTester class that tests all methods. 3/Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in…Given the following class. (JAVA) public class FamilyMember { public String drink( ) {return “cup”;} public String eat( ) {return “fork”;} } Write a Baby class that is derived from the FamilyMember class. The Baby class has an instance variable for the age, a default constructor, and a constructor that accepts an integer. Include any other necessary methods. If a baby is older than 3 years, print that “it eats with its fork”; otherwise, “it eats with its hands”.*using java* Create a class AnimalCreate a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal(String name) //constructor public void makesSound()with the implementation printing out a generic animal sound. Next, override (add) the makesSound()method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don’t make sounds!)Note, you’ll also need a constructor in each of your subclasses which calls super(name) to initialize the common ‘name’ member of Animal. --- Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. ( you should observe the implementation of the makeSound() method called will be: cat -> from Cat class, dog-> from Dog class,…
- class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius=Math.sqrt(xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate&yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…The Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects: essay1 with no arguments essay2 with essayTitle and essayAuthor as arguments essay3 with essayTitle, essayAuthor, and essayYear as arguments Ex: If the input is Painting Cole 1919, then the output is: Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919 Archive.java public class Archive { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringessayTitle; StringessayAuthor; intessayYear; essayTitle=scnr.next(); essayAuthor=scnr.next(); essayYear=scnr.nextInt(); /* Your code goes here */ essay1.print(); essay2.print(); essay3.print(); } } Essay.java public class Essay { private String title; private String author; private int year; public Essay() { // Default constructor title = "Undefined"; author = "Unspecified"; year = 0; }…Java - Polymorphism 1.Create a class named “Animal” that has the method sound() which prints “Animals make sound.” 2.Create a class named “Cat”, “Dog”, “Pig”, “Rat” which all extends the “Animal” class. 3.Override the sound() method from Animal. These are the sound of the animals: Cat - prints "*meow meow*" Dog - prints "*barf barf*" Pig - prints "*oink oink*" Rat - prints "*squeak squeak*" 4.Call the sound() methods in the same order as stated in #3.
- Create a class Animal Create a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal (String name) //constructor public void makes Sound () with the implementation printing out a generic animal sound. Next, override (add) the makes Sound() method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don't make sounds!) Note, you'll also need a constructor in each of your subclasses which calls super(name) to initialize the common 'name' member of Animal. Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. (you should observe the makeSound method called will be: cat -> from Cat class, dog-> from Dog class, bearded Dragon -> from Animal class ) EC:…Static methods within a class are copied into each object created from the class. true or false javaThe following code is in Java: public class Vehicle // Superclass { private double cost; public Vehicle(double c) { cost = c; } (Other methods . . .) // assume these are given and they’re OK. } public class Car extends Vehicle // Subclass { private int passengers; public Car(int p) { passengers = c; } (Other methods . . .) // assume these are given and they’re OK. } 1) What problems are in the code above?2) What is needed to fix the issue of the code?