Concept explainers
Look at the following classes:
public class Ground
{
public Ground()
{
System.out.println(“You are on the ground.”);
}
public Ground(String groundColor)
{
System.out.println(“The ground is ” + groundColor);
}
}
public class Sky extends Ground
{
public Sky()
{
System.out.println(“You are in the sky.”);
}
public Sky(String skyColor)
{
super(“green”);
System.out.println(“The sky is “ + skyColor);
}
}
What will the following
public class Checkpoint
{
public static void main(String[] args)
{
Sky object = new Sky(“blue”);
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Starting Out with Java: Early Objects (6th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java How To Program (Early Objects)
Digital Fundamentals (11th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
- Using JAVA Part A) Design a class Message that models an e-mail message. A message has a recipient, a sender, and a message text. Support the following methods: 1) A constructor that takes the sender and recipient. 2) A method append that appends a line of text to the message body A method toString that makes the message into one long string like: “From: Harry Morgan%nTo: Rudolf Reindee%n . . . “ Write a program that uses this class to make a message and print it. Part B) Design a class Mailbox that stores e-mail messages, using the Message class in part a) Implement the following methods in the Message class. public void addMessage(Message m) // Adds Message M to the Mailbox public Message getMessage(int i) // returns the ith message from the Mailbox public void removeMessage(int i) // removes the ith message from the Mailbox public int mailBoxSize () // returns the number of messages in the Mailbox Write a program to demonstrate the functionality of the Mailbox. Add messages to…arrow_forwardcomplete the following Horse Class with the guidelines provided below public class Horse { // Fields of class Horse // Constructor of class Horse /** * Constructor for objects of class Horse */ public Horse(char horseSymbol, String horseName, double horseConfidence) { } // Other methods of class Horse public void fall() { } public double getConfidence() { } public int getDistanceTravelled() { } public String getName() { } public char getSymbol() { } public void goBackToStart() { } public boolean hasFallen() { } public void moveForward() { } public void setConfidence(double newConfidence) { } public void setSymbol(char newSymbol) { } }arrow_forwardType 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).arrow_forward
- Draw the UML diagram of the following class: public class Employee { String name; double salary; public Employee() { } public double getSalary() { return this.salary; } public String getName() { return this.name; } }arrow_forwardWRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THE PROGRAM : JAVA public class TestMain { public static void main(String[] args) { Invoice check1= new Invoice(112, "Book", 3, 125.98); Invoice check2= new Invoice(101, "Phone", 2, 456.35); Invoice check3= new Invoice(187, "Laptop", 1, 2345.68); check1.displayLine(); check2.displayLine(); check3.displayLine(); } } class Invoice { private int item_number; private String name; private int quantity; private double price; private double total_cost; public Invoice(int item_num, String nm, int quan, double pri) { item_number=item_num; name=nm; quantity=quan; price=pri; total_cost = 0; } public int getitem_number(){ return item_number; } public String getname() { return name; } public int getquantity() { return quantity; } public double getprice() { return price; } public double gettotal_cost() { return total_cost; } public void total() { total_cost=price * quantity; } public void displayLine() { System.out.println("Item…arrow_forwardThe 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; }…arrow_forward
- 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…arrow_forwardclass 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;…arrow_forward**Python code** Write a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives each dog its own name and breed. Test this on a successful creation of a Dog object.>>> import dog>>> sugar = dog.Dog('Sugar', 'border collie')>>> sugar.name'Sugar'>>> sugar.breed'border collie'arrow_forward
- Java Problem. compile and run the code below: /** A class to test the Door class.*/public class DoorTester{ /** Tests the methods of the Door class @param args not used */ public static void main(String[] args) { Door frontDoor = new Door("Front", "open"); System.out.println("The front door is " + frontDoor.getState()); System.out.println("Expected: open"); }} Create a second Door object called “backDoor” with the name property “Back” and an initial state of “closed”. Verify that the object was properly created. Use the mutator to change the state of object backDoor to “open”. Verify that the mutator is working. Create a third Door object called “sideDoor” with the name property “Side” and an initial state of “open”. Verify that the object was properly created. Use the mutator to change the name of object sideDoor to “Front”. Verify that the mutator is working.arrow_forwardGiven 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”.arrow_forward(Java) Question 5 Explain the answer step-by-step and include verbal explanation. Thank you! Write an interface as follows: The interface is named ServiceReminder It has one method named timeForService that has no parameters and returns a boolean variable. Now, update the below class so that is inherits from ServiceReminder Note that the next service date should be 90 days from the last service public abstract class Car { private double gasGauge; private double currMileage; private String color; private String make; private String model; private int daysLastService; public Car(String color, String make, String model, int daysLastService) { this.color = color; this.make = make; this.model = model; gasGauge = 0.0; currMileage = 0.0; this.daysLastService = daysLastService; } @Override public String toString() { return "Make: " + make + "\nModel: " + model + "\nColor: " + color…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education