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
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Modern Database Management
Java How To Program (Early Objects)
Introduction To Programming Using Visual Basic (11th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- What is included in the method private void buildLetterTable() { implemented in the class Anagramsarrow_forwardclass Param3 { public int x; private void increase(int p) { x = x*p; } public void calculateX(int y) { increase(y); } public int getX() { return x; } } // in another class Param3 q3 = new Param3(); q3.x = 5; q3.calculateX(7); System.out.println(q3.getX()); what would be the answer for the last two lines ? also above were x = x*p do both x in here are the fields? wouldn't that be cnofusing?arrow_forwardpublic class Pet { protected String name; protected int age; public void setName(String userName) { name = userName; } public String getName() { return name; } public void setAge(int userAge) { age = userAge; } public int getAge() { return age; } public void printInfo() { System.out.println("Pet Information: "); System.out.println(" Name: " + name); System.out.println(" Age: " + age); } } import java.util.Scanner;public class PetInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Pet myPet = new Pet(); Cat myCat = new Cat(); String petName, catName, catBreed; int petAge, catAge; petName = scnr.nextLine(); petAge = scnr.nextInt(); scnr.nextLine(); catName = scnr.nextLine(); catAge = scnr.nextInt(); scnr.nextLine(); catBreed = scnr.nextLine(); // TODO: Create generic pet (using petName, petAge) and then…arrow_forward
- public class Animal { public static int population; private int age; } public Animal (int age) { this.age = age; population++; } + msg); public void say (String msg) { System.out.print("Saying: " System.out.print(" for "); System.out.print(getHuman Years()); System.out.println(" years."); } public int getHuman Years() { return age; } public class Mammal extends Animal { private String species; public Mammal(String species, int age) { super (age); this. species species; } } } = public int getHuman Years() { if (species.equals("dog")) 1 else return super.getHumanYears() * 7; return super.getHumanYears(); €arrow_forwardQ1. 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_forward
- public class SeperateDuplicates { public static void main(String[ args) { System.out.printIn(seperateDuplicatesChars("Hello")); System.out.printin(seperateDuplicatesChars ("Bookkeeper"')); System.out.printin(seperateDuplicatesChars("Yellowwood door"')); System.out.printin(seperateDuplicatesChars("Chicago Cubs")); */ public static String seperateDuplicatesChars(String str) { //To be completed } }arrow_forwardX2, Y2------1.arrow_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
- What is outpout? public class Vehicle { public void drive(){ System.out.println("Driving vehicle"); } public class Plane extends Vehicle { @Override public void drive(){ System.out.println("Flying plane"); } public static void main(String args[]) { Vehicle myVehicle myVehicle.drive(); } } = new Plane(); syntax error Driving vehicle Flying plane Flying plane O Driving vehiclearrow_forward3 public class ShippingCalculator { public static void main(StringO args) { new Scanner(System.in); 1 st passed 5 Scanner scnr int shipWeightPounds; int shipCostCents = 0; final int FLAT_FEE_CENTS = 75; 7 Altasts passed 8 10 final int CENTS_PER_POUND = 25; System.out.print("Enter shipping weight: "); shipWeightPounds = scnr.nextInt(); shipCostCents = FLAT_FEE_CENTS + shipWeightPounds * CENTS_PER_POUND; 11 12 13 14 15 16 17 System.out.println("Weight(lb): " + shipWeightPounds); 19 Suctom Aut nnin+1nr"Elnt foofconte): ELAT CCE CETS): Run X Testing shipWeightPounds = 10 Output differs. See highlights below. Special character legend Enter shipping weight: Weight (lb) : 10 Flat fee (cents): 75 Your output Cents per pound: 25 Shipping cost (cents) : 325 Weight (1b) : 10 Flat fee (cents): 75 Expected output Cents per pound: 25 Shipping cost (cents): 325 X Testing shipWeightPounds = 2arrow_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_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