plz help with the following: In JAVA Given the following: Which line of code will instantiate an InnerCatobject if inserted after the creation of animal? a)InnerCatcat = animal.newInnerCat(); b)Animal.InnerCatcat = new animal.InnerCat(); c)InnerCatcat = this.newInnerCat(); d)InnerCatcat = new Animal.InnerCat(); Discuss the classes in this question and explain why the other options are incorrect.
Q: Write a Java class called Hotel that represents a hotel. The class will contain the following…
A: In java ArrayList can be resize as an array and it is present under util package. Example of…
Q: Given the below Tesla class, update the class to inherit from the Comparable interface and also…
A: An abstract class can have implemented methods whereas an interface could contain only abstract…
Q: sign of the Ironman and DoctorStrange class derived from Avengers class so that the following code…
A: We need to define the Ironman and DoctorStrange classes as per the given code and output.
Q: Write the Boat class in Java Eclipse. A Boat has a registered name, a number of cabins, and a…
A: I give the code in Java eclipse as per your requirement along with code and output screenshot
Q: Write a loan calculator program in java using intellij that computes both monthly and total payments…
A: In step 2, You will get java code. In step 3, you can see the sample output.
Q: Write a complete Java class that can be used to create a Hamster object as described below: A…
A: The solution for the above given question is given below:
Q: Implement a superclass Father that Make two classes, Boy and Girl that inherit from Father. A Father…
A: Java used to answer this question
Q: Define a new "Degree" class that contains a year (integer), a subject (string) and a person's name…
A: Hey there, I am writing the required solution based on the above stated question. First, I will…
Q: Consider a class that could be used to play a game of hangman. The class has the following…
A: Note - As per the guidelines we're only allowed to answer 1 question at a time. Define a main…
Q: We simply need one method speak() to print out the way that the animal “speaks”. Put the method…
A: public interface Speakable { public void speak(); }
Q: Write a complete program for the description given below. Consider a Billing class that implements…
A: Note: Since you have not provided the language to write the code so I am using Java language to…
Q: PLZ help with the following In JAVA Which line of code will instantiate an InnerCatobject if…
A: Nested Class: In Java, the developer can create a class grouped with some other classes. The main…
Q: PLZ help with the following IN JAVA Given the following Which line of code will instantiate an…
A: Answer is below d)InnerCat cat = new Animal.InnerCat(); So, we use the new keyword to create an…
Q: have no idea what to do. Modify the FitnessTracker class, created in Chapter 4 Programming Exercise…
A: TestFitnessTracker2.java package bartleby; import java.time.*;public class…
Q: Code is in Java find the error in the following class definition: public class MyClass {…
A: public void MyClass(int a, double b) The Above Line Is Incorrect. There Won't be any Return Type…
Q: In this java assignment, we will be creating a paystub for an employee using classes, files,…
A: In the given problem, we need to define three classes (named Employee, PayPeriod, and…
Q: Write a Java program: In the board game Scrabble, each tile contains a letter, which is used to…
A: toString() method returns a string with format: letter + " with value " + value. equals() method…
Q: In this problem, we are going to use ArrayLists and classes to design a road trip. You have three…
A: Actually, Java is a programming language originally developed by James Gosling at Sun Microsystems…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Java Code for above : class HotelRoom{ int RoomNo; String PhoneNumber; int Capacity;…
Q: Consider the following test code placed in the test class within the main() method. Your task is to…
A: Code : Vehicle.java: public class Vehicle { int wheels;String make;String colour; public…
Q: IN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency…
A:
Q: in JAVA Assume that a receipt id contains characters that represent information or that can be used…
A: Below I have provided a java program for the given question. Also, I have attached a screenshot of…
Q: Given below is a Rectangle class consisting of an upper left coordinate and a lower right…
A: ANSWER: public class Point{ int xCoordinate; int yCoordinate;}
Q: For the studentWorker class, create the following: A private int instance variable m hours. A…
A: A class is a group of objects having common properties. A constructor is a method that is used to…
Q: 1. Consider the following lines of coding written in Java, Your teacher went through similar type of…
A: Since you are asking multiple questions, we are doing first question only, if you want solution of…
Q: COMPLETE THE JAVA CODE BELOW SEE ATTACHED PHOTO FOR THE PROBLEM AND THE OUTPUT
A: In Employee class 1. added to String method 2. added earning method calculate earning by…
Q: Write the Boat class in Java Eclipse. A Boat has a registered name, a number of cabins, and a…
A: The following is the source code for the given statements in the question.
Q: Consider the following classes: public class Topl int x; public Top (int x) { this.x = x + 1; }…
A: What will be displayed on screen from the Java code?
Q: This time we want the Animal greeting method to be modified so that it will be: Hello, my name is…
A: It is defined as programs can be asked from control statements, array, string, oops etc. Java basic…
Q: Fill in the missing code for the Range class below. Upload your Range.java. public class Range…
A: The setters and getters methods are used for encapsulation in object oriented paradigm. The…
Q: Suppose you are an owner of a car wash & service center. Now, implement the design of the Car class…
A: The answer is..
Q: In this java assignment, we will be creating a pay stub for an employee using classes. Each class…
A: The above program makes use of Scanner class defined within java.util package that is used to take…
Q: Write a Java program containing two classes: Dog and a driver class Kennel. The Dog dlass consists…
A: Given :- Write a love program containing two classes: Dog and a driver class Kennel.Dog class…
Q: For this assignment, create a child class of car that creates a car of a randomly generated color.…
A: //Adding the package package javafx.swing; //Importing the required header files import…
Q: ng method must return all the degree information: year, subject and person’s name in the following…
A: Here is C++ program:
Q: in JAVA Assume that a receipt id contains characters that represent information or that can be used…
A: Below I have provided a java program for the given question. Also, I have attached a screenshot of…
Q: In python, create a class horse that inherits the following attributes and methods from its parent…
A: #Parent class class Animal: #constructor def __init__(self,common_name, given_name, weight):…
Q: This assignment starts with the Account class from Labs 4 and 5. Our new and improved bank has two…
A: package inheritance; import java.util.*; class Bank { Scanner s=new Scanner(System.in);…
Q: In this exercise, you have to implement a calculator which can perform addition, subtraction,…
A: public class Calculator {double num1,num2; public Calculator( double num1,double num2) {…
Q: For this exercise, you will be completing the Account class, which simulates a regular bank account,…
A: LOGIC: The given problem will have below three classes: a) Account.java: A base class to hold…
Q: 5) Consider the Clock class, which represents the passage of time. The tick() method adds one minute…
A: Consider the Clock class, which represents the passage of time. The tick() method adds one minute to…
Q: Hi, can i please get assistance with the following Java class below, where there is "TO DO:" I would…
A: In Insertion method, it is clearly mentioned that no duplication is allowed. So, we have to use Set…
Q: Write the dry run of the following program ( Java-OOP) Define a class named Money whose objects…
A: class Money{ int dollars, cents; //constructor with two parameters of type int for the…
Q: Suppose class B is derived from class A, and class C is derived from class B. In other words, we…
A: Child class variables can use parent class objects. However, parent class variables cannot utilize…
Q: We will write an Account class that represents a (simplified) bank account. A bank account keeps the…
A: Solution: Given, acc1 = Account('MUIC', 'A12345', 500)acc2 = Account('CS', 'A67890', 0)…
Q: write the following 3 classes for the Java program so that this program produces the sample output…
A: *Note: Save the code in a file named "Main.java" otherwise it will not compile. This is because,…
Q: Write a java class called House with the following two private attributes, and three methods:…
A: Class is a user-defined custom data type that encapsulates the data members and member…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Given: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
plz help with the following:
In JAVA
Given the following:
Which line of code will instantiate an InnerCatobject if inserted after the creation of animal?
a)InnerCatcat = animal.newInnerCat();
b)Animal.InnerCatcat = new animal.InnerCat();
c)InnerCatcat = this.newInnerCat();
d)InnerCatcat = new Animal.InnerCat();
Discuss the classes in this question and explain why the other options are incorrect.
Step by step
Solved in 3 steps with 4 images
- 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)…public class StringArrayManipulation { public static double getSum(String[][] data) { ????? // code goes here } public static void main (String[] args) { String [][] data = { {"Abc,1abc2,12.3,23 west,7.88"}, {"sdf,1agdfgdfgdfgbc,2342.3,23 east,34.34"}, {"Abrgdfhc,1adfbc2,132.3,22 west,34.2"}, {"Abthhc,1adffdggbc2,142.3,21 west,23.5"}, {"ryreyh,1arttt4t43bc2,1232.3,233 west,325.55"}, {"Abbbgfbfgbc,1abrgfhfbc2,152.3,53 west,45.34"}, {"A5yyeybc,1a454tbc2,89.7,26 west,325.6"}, {"Ah5yybc,1afg3bc2,28.9,28 west,234.2"} }; System.out.println("Expected output: 4132.4, output: " + getSum(data)); } }Write a Java class Student inherited from Person class. Your class must have the following features: Student - major: String + Student() + Student(name: String, id: int, major: String) + getMajor(): String + Override toString() method: you have to return needed data Fields values. Note: major data members can take only CS for Computer Science, CIS for Computer and Information Systems, CPE for Computer Engineering, SE for Software Engineering, and NES for Network Engineering and Security.
- **Students.java code** // A Java program to demonstrate use of Comparableimport java.util.*; // A class 'Student' that implements Comparableclass Student implements Comparable<Student>{ private String FirstName; private String LastName; private int StudentID; // Used to sort movies by year public int compareTo(Student a) { return this.StudentID - a.StudentID; } // Constructor public Student(String fm, String ls, int id) { this.FirstName = fm; this.LastName = ls; this.StudentID = id; } // Getter methods for accessing private data public String getFirstName() { return FirstName; } public String getLastName() { return LastName; } public int getStudentID() { return StudentID; }} // Driver classclass Students{ public static void main(String[] args) { ArrayList<Student> list = new ArrayList<Student>(); list.add(new Student("Amir", "Alao", 123456)); list.add(new…Class Die java.lang.Objectextended by Diepublic class Dieextends java.lang.ObjectDie - an n-sided die with given integer values. The given integer values are returned via nextRoll() with uniform probability., Constructor SummaryDie() Creates a new Die instance with the default values: 1, 2, 3, 4, 5, 6.Die(int[] outcomes) Creates a new Die instance with the given integer outcomes.Die(int sides, int min) Creates a new Die with a given number of sides and an incremental sequence of values beginning with a given minimum value.Method Summaryint nextRoll() nextRoll - return one of the die values at random.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitConstructor DetailDie public Die(int[] outcomes)Creates a new Die instance with the given integer outcomes.Parameters:outcomes - an int[] value - an array of the integer values for each side of the die.Die public Die(int sides,int min)Creates a new Die with…An arithmetic progression is a sequence of numbers such that the difference between the consecutive terms is constant. For instance, the sequence 5, 7, 9, 11, 13, 15 is an arithmetic progression with a common difference of 2.Given the class IntNumber:1 public class IntNumber2 {3 public final int value;45 public IntNumber(int number) {6 this.value = number;7 }8 }where value is an immutable field, that can be directly accessed (public), implement a class called ArithmeticProgressionthat implements the following methods:•1 public static IntNumber getArithmeticProgressionDifference(ArrayList<IntNumber> list)which returns the difference between terms of the arithmetic progression (as an object of type IntNumber) if thevalues of the IntNumber objects are an arithmetic progression. The method returns null in any other case.•1 public static void printIsArithmeticProgression(ArrayList<IntNumber> list)which prints on the console:The list is an arithmetic progression with difference =…
- Go off this code: public abstract class Employee{private String firstName;private String lastName;private String SSN;double salary; public Employee( String first, String last, String ssn ){firstName = first;lastName = last;SSN = ssn;} public void setfirstName( String first ){firstName = first; // should validate} public String getfirstName(){return firstName;} public void setlastName( String last ){lastName = last; // should validate} public String getlastName(){return lastName;} public void setSSN( String ssn ){this.SSN = ssn;}public String getSSN(){return SSN;} @Overridepublic String toString(){return String.format( "%-12s%-12s%-12s", getfirstName(), getlastName(), getSSN() );}public abstract double earnings();}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;…import bridges.base.ColorGrid;import bridges.base.Color;public abstract class Mark {// this is protected (rather than private) so that// subclasses of Mark can access itprotected Color color;/*Returns true if and only if the given Coloris the same as this Mark's Color. Two Colorsare considered the same if their Red, Green,Blue, and Alpha components are equal.c: the Color to check against*/public boolean isColor(Color c) {return false;}/*Draws this Mark onto the given ColorGridcg: the ColorGrid to draw onto*/public abstract void draw(ColorGrid cg);} import bridges.base.Color;import org.junit.Assert;import org.junit.Test;public class MarkTest {private static final Color B = new Color("black");private static final Color W = new Color("white");private static final Color U = new Color("blue");@Testpublic void isColorTest() {Mark m1 = new Point(0, 0, W);Mark m2 = new HorizontalLine(1, 1, 2,…
- public class OfferedCourse extends Course { // TODO: Declare private fields // TODO: Define mutator methods - // setInstructorName(), setLocation(), setClassTime() // TODO: Define accessor methods - // getInstructorName(), getLocation(), getClassTime() } import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, location, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); location = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle);…this code is in java.Explore the given classes. Implement a getter method on the WasteRobot class with the following method signature public ArrayList<Waste> getWasteBin(String wasteType) The method should return the proper waste bin based on the passed wasteType. Compare the given wasteType to each of the public static final constants in the Waste class to help determine which bin to return.Given Classes :WasteRobotTester.java import java.util.*; public class WasteRobotTester{ public static void main(String[] args) { WasteRobot wallie = new WasteRobot(); // Your test code. }}WasteRobot.java import java.util.*; public class WasteRobot{ private ArrayList<Waste> trashBin; private ArrayList<Waste> compostBin; private ArrayList<Waste> recyclingBin; public WasteRobot() { trashBin = new ArrayList<Waste>(); compostBin = new ArrayList<Waste>(); recyclingBin = new ArrayList<Waste>();…Write a 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) a. Extend a Circle class from Point class such as Class Circle extends Pointb. Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1;c. Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter.Now write a ColoredCirlce class with private instance variable as color (String) and public setter & getters. Extend the ColoredCircle from Circle and do the following operations.d. Write a default constructor…