Look at the following class:
public class Checkpoint
{
public void message(int x)
{
System.out.print(“This is the first version ”);
System.out.println(“of the method.”);
}
public void message(String x)
{
System.out.print(“This is the second version ”);
System.out.println(“of the method.”);
}
}
What will the following code display?
Checkpoint cp = new CheckPoint( );
cp.message(“1”);
cp.message(1);
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Absolute Java (6th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Database Concepts (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
C Programming Language
- 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.arrow_forward(Java) 7.2 Code: Look at the following Person.java class code: class Person{public String name;public int age;public String gender;public void greeting() {System.out.println( "Hi, my name is " + name + "!");}public void greeting(String otherName){System.out.println("Hi, " + otherName + "!");}public void printPerson () {System.out.println("Name: "+name);System.out.println("Age: "+age);System.out.println("Gender: "+gender);System.out.println();}} Remove the printPerson method from this class. Instead, write a toString() method that can be used to display the Student Object in the following manner: Name: <The Name> Age: <The Age> Gender: <The Gender> Note the use of the <> above. Do not add these <> to your String. Instead, these <> are commonly used to mean a value will be filled in later. Don't forget the @Override tag in front of the toString() method image source Using the below starter code and the toString method, we will…arrow_forwardWhat is included in the method private void buildLetterTable() { implemented in the class Anagramsarrow_forward
- 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_forwardJava 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.arrow_forwardUML Diagrams: Course -courseName: String -students: Student [] -numberOfStudents: int +Course(courseName : String) +getCourseName() : String +addStudent (student : Student) : void +addStudent (studentName: String): void +dropStudent(studentId: int ) : void +getStudents() : Student [] +getNumberOfStudents() : int a. How many constructors does Course have? b. How many methods that are void? c. How many methods that return a value? d. What is the parameter to the method dropStudent?arrow_forward
- Convert the following UML diagram into the Java code. Write constructor, mutator and accessor methods for the given class. Create an instance of the class in a main method using a Demonstration class. Note: The structure of the class can be compiled and tested without having bodies for the methods. Just be sure to put in dummy return values for methods that have a return type other than void. Exercise Log ExerciseID: integer ExerciseCategory: string TimeSpent: float Calories: floatarrow_forwardpublic class ClassA { public void methodOne(int i) { } public void methodTwo(int i) { } public static void methodThree(int i) { } public static void methodFour(int i) { } } public class ClassB extends ClassA { public static void methodOne(int i) { } public void methodTwo(int i) { } public void methodThree(int i) { } public static void methodFour(int i) { } } a. Which method overrides a method in the superclass? b. Which method hides a method in the superclass? c. What do the other methods do?arrow_forwarduse Java. Given the following class. 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
- 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; }…arrow_forwardJAVA Class and Object WRITE THE OUTPUTS OF THE FOLLOWING!!! A.) public class MyClass { static void myMethod() { System.out.println("Hello World!"); } public static void main(String[] args) { myMethod(); } } B.) public class Car { public static void main(String[] args) { Car myCar = new Car(); myCar.fullGear(); myCar.speed(200); } public void fullGear() { System.out.println("The car is going as fast as it can!"); } public void speed(int maxSpeed) { System.out.println("Max speed is: " + maxSpeed); } }arrow_forwardThe BankAccount class models changes to the balance of a person’s savings account. public class BankAccount { public BankAccount(String name, double initBal) public double getBalance() public String getName() public void deposit(double amount) public void withdraw(double amount) public void transferTo(BankAccount otherAcct, double amt) public boolean equals(Object other) private String acctName; private double balance; } Provide the code for the transferTo(…) Briefly explain why there is no setBalance() method in this class.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