Consider the following code snippet. public interface Measurable { double getMeasure): } public class Coin implements Measurable { public Coin(double aValue. String aName) { .-- } public double getMeasure) { return value; } } public class BankAccount implements Measurable { public BankAccount(double initBalance) {.. } public void getMeasure) { return balance; } Which of the following statements is correct? Justify your choice. a) Coin dime = new Coin(0.1, "dime"); BankAccount b = (Measureable)dime; b) Measureable m=new BankAccount(1000); BankAccount b =m; c) Coin dime = new Coin(0.1, "dime"); Measurable m = dime; d) Measurable m =new Coin(0.1, "dime"); Coin dime = m;
Q: Write a Hamster class that is a subclass of Pet. Include: an additional attributes called…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Create a constructor of MyClass, and call it: class MyClass { public: cout <« "Hello World!"; }; int…
A: Constructor name of a class is same as class name.
Q: Write a Java class Person for dealing with persons. Your class must have the following features:…
A: As per the requirement person class is developed. Note: As per our guidelines we are suppose to…
Q: Model the world described below by defining proper OOP items (i.e. class, abstract class, interface…
A: Here, Bird will be the Super class and all the remaining classes are subclasses
Q: Movable «interface>> +moveUp(): void +moveDown (): void +moveleft():void +moveRight():void abstract…
A: Movable.java public interface Movable { void moveUP(); void moveDown(); void moveLeft();…
Q: Create a classstudent which includes parameters roll_no, name and address and consider as super…
A: //code import java.util.Scanner; class Student3 { void Student(int roll, String name,int…
Q: Write a Java class Person for dealing with persons. Your class must have the following features:…
A: class Person{ long person_id; String name,gender; //default constructor Person(){…
Q: (Classes and Objects) Hand-write a complete Java class that can be used to create a Car object as…
A: Instance variable in private scope. Using this pointer within default constructor with no arguments.…
Q: Implement the following classes / abstract classes below. Monster abstract class which has health…
A: public class Main { public static void main (String[] args) { //create 3 instances and…
Q: Design a class Circle with the following Private double data for radius One no arg constructor One…
A: //note: since the programming language is mentioned we are providing answer in cpp #include…
Q: Description: Create a class named ComparableDog that extends Animal and implements Comparable…
A: Find the required code in java given as below and output :
Q: Create an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle with…
A: Create an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle with…
Q: interface IResit { int number = 3; char iChar = #"; interface IShape extends IResit { public void…
A: There are certain points to keep in mind while reading the given code: Methods declared in…
Q: Consider the following code snippet. public interface Measurable { double getMeasure); } public…
A: Java provides upcasting implicitly and downcasting explicitly. If you try to do downcasting…
Q: s that will extend the given Animal class and optionally implement a leg count interface. (Image…
A: Given : Animal.java abstract class Animal { String FUR="fur"; String FEATHER = "feather"; String…
Q: Implements Cloneable interface. Contain two member variables RollNo & Name. Initialize member…
A: 1- In this assignment require, implement a cloneable interface, two string types variable(roll no,…
Q: Write a class named Person with data attributes for a person’s name, address, and telephone number.…
A: class Person: def __init__(self, name, address, number): self.name = name…
Q: In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The…
A: Constructor is the same name as that class name, and it is invoked when the object of that class is…
Q: In java Create an abstract super class called Employee with the following attributes: name :…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: JAVA WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THESE PROGRAM : A.) public class…
A: In the given program code, we define a class Invoice with private members integer type item_number,…
Q: Assume the class Student implements the Speaker interface from the textbook. Recall that this…
A: HERE IS COMPLETE CODE WITH OUTPUT
Q: Given the following code, which statement is correct? class Coffee ( } class Sugar { } class Cup {…
A: Composition class: As inheritance composition class is used for reusing the code. The composition…
Q: It has just one Main class which tests abstract class Animal and its 3 subclasses: Dog, Cat, and…
A: //declaring interfacepublic interface Talker{ //declaring abstract methods public void…
Q: The interface Speaker is describe below. public interface Speaker{ public void speak(); public void…
A: // Speaker.java // Speaker Interface public interface Speaker { public void speak(); public…
Q: in java write a class Vessel (2 methods, 2 properties ,one of them is speed). Extend this class into…
A: Purpose: In this we are considering a class vessel with all the conditions given and from that we…
Q: It has just one Main class which tests abstract class Animal and its 3 subclasses: Dog, Cat, and…
A: Question given: A program code is given of driver class. Write all classes and their method that…
Q: What is the output of the following code? public interface yourInterface { int x = 10, y = 20; void…
A: Interface: Interface in java is abstract type. The methods of interface are implemented by classes.…
Q: java Prepare an abstract class SpecialColor with one property the color name (String) and two…
A: The three classes will be created as follows: Class SpecialColor This class has one attribute called…
Q: In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The…
A: Problem: In the following, there are two classes, Employee and Manager. Manager is a subclass of…
Q: public abstract class Landmark { public abstract int countVisitors(); } Consider the class shown…
A: Data Abstraction is an OOP concept that hides the background details. It shows only those…
Q: Text Class The Text class inherits from Drawable and it will be used to display the player's score.…
A: It is defined as an interpreted, object-oriented, high-level programming language with dynamic…
Q: class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance…
A: Program code: Filename: Point class(PointClass.java) class PointClass{ private int xCoordinate;…
Q: The Fine class must implement an iFine interface that contains the following: public interface iFine…
A: //SpeedingFineApplication.javaimport java.util.Scanner;public class SpeedingFineApplication{…
Q: write all the code necessary for a class Toaster as described here. A toaster can be described as…
A: Introduction: Needs to create a JAVA program with given fields. There should be a default…
Q: In Java Use inheritance to create the class PassengerPlane. An object of this class includes a…
A: Introduction of the Program: The Java Program uses the concept of inheritance. Here the Airplane…
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: n the following statement: public abstract class Vehicle extends DD implements Car{ . . . } DD must…
A: Note: Please note that we are only allowed to solve one question in one post. if you want to get…
Q: A. Write the classes as shown in the following class diagram. Movable is an interface and…
A: Movable.java public interface Movable { void moveUP(); void moveDown(); void moveLeft();…
Q: Many city ordinances have a requirement that buildings be surrounded by a certain amount of empty…
A: Given: Information regarding buildings in a city is provided and a class Building is created along…
Q: What is the output of the following code? public interface yourInterface { int x = 10; %3D int y =…
A: Operators are the fundamental building blocks of all programming languages. Java, too, has a variety…
Q: Given the following superclass: abstract class Shape { private int sides; abstract double…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Consider the following class definition: public class MyClass private int value; public void set…
A: Answer: Given Code is: public class MyClass { private int value; public void setValue(int i){ }
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: Implements Cloneable interface. Contain two member variables RollNo & Name. Initialize member…
A: Java code: import java.util.*; // class Student implements Cloneable interface.class Student…
Q: Write a program in Java that performs the following tasks: Creates a class called Person having…
A: Step 1:- Program Approach:- 1.Create class Person with the attributes personName and personId and…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- *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,…In Java Your uncle is trying to keep track of his new-car and used-car lots by writing a Java program. Heneeds your help in setting up his classes.Implement a superclass named Car that contains a price instance variable, a getPrice method, anda 1-parameter constructor. The getPrice method is a simple accessor method that returns the priceinstance variable’s value. The 1-parameter constructor receives a cost parameter and assigns avalue to the price instance variable based on this formula:price = cost * 2;Implement two classes named NewCar and UsedCar; they are both derived from the Carsuperclass. NewCar should contain a color instance variable (the car’s color). UsedCar shouldcontain a mileage instance variable (the car’s odometer reading). The NewCar and UsedCarclasses should each contain a 2-parameter constructor, an equals method, and a toString() method.In the interest of elegance and maintainability, don’t forget to have your subclass constructors callyour superclass constructors…It has just one Main class which tests abstract class Animal and its 3 subclasses: Dog, Cat, and Fish. It also tests the Talkers: Dog, Cat, and Radio. So your job is to write all 6 of these simple classes (they should be less than one page each) : Talker.java - the interface Talker, which has just one void method called speak() Animal.java - the abstract class Animal, which stores an animal's name. (No abstract methods). It should contain 2 methods: a constructor with 1 argument (the name) a method getName() which returns the name. Dog.java - the class Dog, which extends Animal and implements Talker. It should contain 3 methods: a constructor with no arguments, giving the dog a default name of "Fido" a constructor with 1 argument (the name) a speak() method that prints "Woof" on the screen. Use @Override Cat.java - the class Cat, which extends Animal and implements Talker. It should contain just 2 methods: a constructor with 1 argument (the name) (no default name like dogs…
- It has just one Main class which tests abstract class Animal and its 3 subclasses: Dog, Cat, and Fish. It also tests the Talkers: Dog, Cat, and Radio. So your job is to write all 6 of these simple classes (they should be less than one page each) : Talker.java - the interface Talker, which has just one void method called speak() Animal.java - the abstract class Animal, which stores an animal's name. (No abstract methods). It should contain 2 methods: a constructor with 1 argument (the name) a method getName() which returns the name. Dog.java - the class Dog, which extends Animal and implements Talker. It should contain 3 methods: a constructor with no arguments, giving the dog a default name of "Fido" a constructor with 1 argument (the name) a speak() method that prints "Woof" on the screen. Use @Override Cat.java - the class Cat, which extends Animal and implements Talker. It should contain just 2 methods: a constructor with 1 argument (the name) (no default name like dogs…1). Write a java abstract class called Solid and you will derive two classes – Cylinder and Sphere – from Solid. The class Solid Member variables type whose data type is String. For example, the type could be sphere, cube, parallelepiped. 2). The methods should include: A default or null constructor A constructor that initializes the value of type Getters and Setters An abstract method to find volume whose signature is public abstract double findVolume(); An abstract method to find surface area whose signature is public abstract double findSurfaceArea() a toString method that returns a string like the following Solid Type: Sphere an equals method that returns true if two Solid objects have the same type and false otherwise. 3). The class Cylinder - Cylinder will extend Solid Member variables: Cylinder inherits type from Solid radius of type double height of type double Methods: a default or null constructor a constructor that initializes type, radius, and height. type will always…1). Write a java abstract class called Solid and you will derive two classes – Cylinder and Sphere – from Solid. The class Solid Member variables type whose data type is String. For example, the type could be sphere, cube, parallelepiped. 2). The methods should include: A default or null constructor A constructor that initializes the value of type Getters and Setters An abstract method to find volume whose signature is public abstract double findVolume(); An abstract method to find surface area whose signature is public abstract double findSurfaceArea() a toString method that returns a string like the following Solid Type: Sphere an equals method that returns true if two Solid objects have the same type and false otherwise. 3). The class Cylinder - Cylinder will extend Solid Member variables: Cylinder inherits type from Solid radius of type double height of type double Methods: a default or null constructor a constructor that initializes type, radius, and height. type will always…
- write all the code necessary for a class Toaster as described here. A toaster can be described as having a model (string), manufacture(string), and price. include the following methods in your class definition.(in java) 1. a default constructor2. an overloaded constructor takes the model and manufacture as input.3. an accessor method to acquire the price.4. a tostring method that returns a reasonable description of the toaster.in java A class Book is designed to model a book written by one author. It contains: Four private instance variables: name (String), price (double) static, and qty (int); Two constructors: public Book (String name, double price) { ...... } public Book (String name, double price, int qty) { ...... } getters/setters methods getName(), getPrice(), setPrice(), getQty(), setQty(). A toString() that returns book values. A class called Author is designed to model a book's author. It contains: Four private instance variables: name (String), email (String), and gender (char of either 'm' or 'f') and arrayList of Books. One constructor to initialize the name, email and gender with the given values; public Author (String name, String email, char gender) {......} public getters/setters. A toString() method that returns author object. A method addBook(Book b) which will add book in the Arraylist of books. A removeBook(String name)…In java Create an abstract super class called Employee with the following attributes: name : String and the following methods getter and setter for the one attribute three constructors an abstract method called getSalary() equals() toString() Create a sub class of Employee called Faculty with the following attribute yearlyPay : double department: String and the following methods getter and setter for the attributes three constructors getSalary() that returns the yearlyPay divided by 52 equals() toString() Create a sub class of Employee called Staff with the following attributes: hoursWorked : double payrate : double and the following methods getters and setters for the two attributes three constructors getSalary() that returns the weekly pay (multiply hoursWorked by payrate, overtime included and 1.5 times payrate for hours > 40) equals() toString() Create a sub class of Employee called Sales with the following attributes: salesAmount : double //sales per week…
- Write classes that will extend the given Animal class and optionally implement a leg count interface. (Image attached below, use Java) abstract class Animal { String FUR="fur"; String FEATHER = "feather"; String SCALE = "scale"; String SHELL = "shell"; String SKIN = "skin"; abstract String getCovering( ); abstract void makeSound ( ); abstract boolean canFly( ); } You will need to write: Classes for the animals mentioned above A leg count interface Main method to demonstrate that all of your classes workJava program Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type String. Supply a method toString that prints the manager’s name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate toString methods for all classes. Supply a test program that tests these classes and methods.package edu.umsl;interface Jumpman {void jump();default void swingHammer() {// Code to swing hammer}}public class Main implements Jumpman {public static void main(String[] args) {}} What would you, as the programmer, need to minimally do, if anything, to fix the above code? Group of answer choices Class 'Main' must either be declared abstract or implement abstract methods 'jump()' and 'swingHammer()' in 'Jumpman'. Nothing, this code works as is. Class 'Main' must either be declared abstract or implement abstract method 'jump()' in 'Jumpman'. Class 'Main' must implement abstract method 'swingHammer()' in 'Jumpman'.