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 Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Q1. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } Q2. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here }…arrow_forwardpackage movie;import java.util.Scanner; public class Movie{private String name;private double rating;Scanner sc=new Scanner(System.in);public void setMovieName(String str){name=str;}public void setMovieRating(double rat){rating=rat;}public String getMoviename(){return name;}public double getMovieRating(){return rating;}} class TestMovie{public static void main (String[] args) {Movie m1=new Movie();Movie m2=new Movie();Movie m3=new Movie();m1.setMovieName("Transformers");m1.setMovieRating(3.4);m2.setMovieName("Aliens");m2.setMovieRating(4.5);m3.setMovieName("Hellboy");m3.setMovieRating(4.0);System.out.println("\nMovie name: "+m1.getMoviename()+"\nMovie rating: "+m1.getMovieRating());System.out.println("\nMovie name: "+m2.getMoviename()+"\nMovie rating: "+m2.getMovieRating());System.out.println("\nMovie name: "+m3.getMoviename()+"\nMovie rating: "+m3.getMovieRating());}} what is wrong with my code I need help pls make it in the correct format and explain what is wrong with itarrow_forward1 a. is the amount the same, yes or no, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } b. public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here } } c. is the…arrow_forward
- C# Methodarrow_forwardIn the Test class as shown below, there are a total of () constructors. public class Test{ private int x; public Test(){ x=35; } } public void Test(double f) { This.x=(int)f; } public Test(String s){} 0 O 1 2 3arrow_forwardprivate float c; private void method2(double y) { c = y; } in another class we created an object of the first class then within in it : tester.method2 (10.0f); are there any errors ? how many errors if there are any and with explanation please.arrow_forward
- public class Secret private int x; private static int y; public static int count; public int z; public Secret () } X ?t = 2 { public Secret (int a) } { public Secret (int a, int b) } { public String toString() return ("x = " count = " + count); { public static void incrementY () { { 54. How many constructors are present in the class definition above? C. 2 d. 3 b. 1 55. What does the default constructor do in the class definition above? a. Sets the value of x to 0 c. Sets the value of x to 0 and the value of z to 1 d. There is no default constructor. b. Sets the value of z to 1 56. Based on the class definition above, which of the following statements is illegal? Secret.incrementY (); b. Secret.count++3B a. c. Secret. 2++; d. None of these 13arrow_forwardGIVEN //BookMain.java//This is the client code of Book class public class BookMain{ public static void main(String[] arguments){// Small test of the Book classBook example = new Book("Angels and Demons");System.out.println("Title (should be Angels and Demons): " + example.getTitle());System.out.println("Rented? (should be false): " + example.isBorrowed());example.rented(); //marks the book as rentedSystem.out.println("Rented? (should be true): " + example.isBorrowed());example.returned();//marks the book as returnedSystem.out.println("Rented? (should be false): " + example.isBorrowed());} GIVEN //Book.java//complete the missing implementation to this class public class Book{private String title;private boolean borrowed; // Creates a new Book (constructor)public Book(String bookTitle){// Implement this method} // Marks the book as rentedpublic void rented() {// Implement this method} // Marks the book as not rentedpublic void returned() {// Implement this method} // Returns true if the…arrow_forwardpublic class KnowledgeCheckTrek { public static final String TNG = "The Next Generation"; public static final String DS9 = "Deep Space Nine"; public static final String VOYAGER = "Voyager"; public static String trek(String character) { if (character != null && (character.equalsIgnoreCase("Picard") || character.equalsIgnoreCase("Data"))) { // IF ONE return TNG; } else if (character != null && character.contains("7")) { // IF TWO return VOYAGER; } else if ((character.contains("Quark") || character.contains("Odo"))) { // IF THREE return DS9; } return null; } public static void main(String[] args) { System.out.println(trek("Captain Picard")); System.out.println(trek("7 of Nine")); System.out.println(trek("Odo")); System.out.println(trek("Quark")); System.out.println(trek("Data").equalsIgnoreCase(TNG));…arrow_forward
- Java programming language I need the two classes ( the testing class and the class with the methods) to be combined into one class. This is the program: import java.util.Scanner; //The Temperature Class Begins Here public class Temperature { private double ftemp; //The constructor public Temperature(double ftemp) { this.ftemp = ftemp; } //Get farenheit Method public double getFtemp() { return ftemp; } //Set farenheit method public void setFtemp(double ftemp) { this.ftemp = ftemp; } // Get Celcius Method public double getCelcius(double ftemp){ //double celcius = (double) (5/9) * (ftemp - 32); double celcius = (ftemp-32)* (double)5/9; return celcius; } // Get Kelvin Method public double getKelving(double ftemp){ double Kelvin; Kelvin = (ftemp-32)*(double)5/9 + 273.15; return Kelvin; } } //The Temperature Class Ends Here //The Temperature Test Class with a main method begins Here class…arrow_forwardJava: ShowStudent.java: class ShowStudent { public static void main (String args[]) { Student pupil = new Student(); pupil.setIdNumber(234); pupil.setPoints(47); pupil.setHours(15); pupil.showIdNumber(); pupil.showPoints(); pupil.showHours(); System.out.println("The grade point average is " + pupil.getGradePoint()); } } ShowStudent2.java: class ShowStudent2 { public static void main (String args[]) { Student pupil = new Student(); pupil.showIdNumber(); pupil.showPoints(); pupil.showHours(); System.out.println("The grade point average is " + pupil.getGradePoint()); } } Student.java: class Student { // the private data members private int idNumber; private int hours; private int points; // Constructor added in part c Student() { } // end of constructor added in part c // the public get and set methods public void…arrow_forwardpublic class CallStack{ // Called by func1() void func2 (){ System.out.println("In func2 method"); int a = 0; int b; b = 10 / a; } //Called by Main void func1(){ System.out.println("In func1 method"); this.func2 (); System.out.println("Back in func1 method"); } public static void main (String args[]){ CallStack myCallStack; myCallStack = new CallStack(); System.out.println("In the main method"); try { myCallStack.func1 (); }catch (ArithmeticException e) { System.out.println("Can't divide by Zero!"); } } } Examine the code to determine what it does. Compile and execute the code. Modify the main() method to handle the exception that is propagated to it. Use a try- catch block to display a meaningful error message when the exception occurs. Test your code. Notice that, although the exception was thrown in func2, it is caught by the catch block in the main method.arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage