What will the following
public class Checkpoint
{
public static void main(String[ ] args)
{
int num1 = 99;
double num2 = 1.5;
System.out.println(num1 + “ ” + num2); myMethod(num1, num2);
System.out.println(num1 + “ ” + num2);
}
public static void myMethod(int i, double d)
{
System.out.println(i + “ ” + d);
i = 0;
d = 0.0;
System.out.println(i + “ ” + d);
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Problem Solving with C++ (9th Edition)
Database Concepts (7th Edition)
- Trace and document every step of execution of the following program: public class Trace { public static void main(String[] args) { int[] num = {1, 3, 6, 9, 12 }; for (int i = 4; i >= 0; i--) { num[i] +=1; } num[0] *=num[4]; } }arrow_forwardpublic class MysteryReturn2 {3 public static void main(String[] args)4 {5 int x = 1;6 int y = 2;7 int z = 3;89 z = mystery(x, z, y);10 System.out.println(x + " " + y + " " + z);11 }1213 public static int mystery(int c, a, int b);14 {15 c--;16 a = 2 * b + c;17 b = a - 1;18 System.out.println(b + " " + c);1920 return a;21 }22 } 1. Line 13 contains 2 errors. What are they? 2. Rewrite line 13 with the errors identifed in Question 1 corrected.arrow_forwardRewrite the private static int recurseMax method without using Java API public class Recursion{ public static void main(String[] args){ // My tests (DO NOT MODIFY!) int[] a = {3,2,6,4,15,7,9,8,6}; p(recurseSum(a)); // Sum should be 60 p(recurseMax(a)); // Max should be 15 // End of tests! } // Recursive methods below here... public static int recurseSum(int[] a){ // TODO: This is the wrapper method. You must complete this AND implement helper method int total = recurseSum(a, a.length); return total; } private static int recurseSum(int[] a, int i){ if (i <= 0) return 0; return (recurseSum(a, i - 1) + a[i - 1]); } public static int recurseMax(int[] a){ int max = recurseMax(a, a.length); return max; } private static int recurseMax(int[] a, int i){ if(i == 1) return a[0]; return Math.max(a[i-1], recurseMax(a, i-1)); } //…arrow_forward
- Fast in java coding please. Thank you What will the following program print?public class CompleteConcept {public static void main(String[] args){ String a = new String("HelloUniverse!");System.out.println(a.toUpperCase());System.out.println(a.toLowerCase());System.out.println(a.length());System.out.println(a.charAt(0));System.out.println(a.indexOf('e'));System.out.println(a.indexOf("Uni"));System.out.println(a.substring(6));System.out.println(a.substring(6, 9));System.out.println(a.equals("hello universe!"));System.out.println(a.equalsIgnoreCase("hello universe!"));System.out.println(a.startsWith("Hello"));System.out.println(a.startsWith("Uni", 6));System.out.println(a.endsWith("e!"));System.out.println(a.contains("Uni"));System.out.println(a.replace('e', 'u'));System.out.println(a.replace("ll", "lll"));a = " A B C \n ";System.out.println(a.trim());}}arrow_forwardpublic class main { public static void main(String [] args) { Dog dog1=new Dog(“Spark”,2),dog2=new Dog(“Sammy”,3); swap(dog1, dog2); System.out.println(“dog1 is ”+ dog1); System.out.println(“dog2 is ”+ dog2); } public static void swap(Dog a, Dog b) { String nameA = a.getName(); String nameB = b.getName(); a.setName(nameB); b.setName(nameA); } What is the output of the main()?arrow_forwardpublic class Myclass{ private static int count=0; private int x; //} public Myclass(int i) { x=i; } public void incrementCount(){ count++; } public void printX(){ System.out.println("Value of x : "+ x); } public static void printCount(){ System.out.println("Value of Count : "+count); } } public class MyclassDemo{public static void main(String[] args){ Myclass myObject1 = new Myclass(5); Myclass myObject2 = new Myclass(7); }} what is the outputof the following java code? (Assume that following statements are written inside main) g) my Object1.setX(14); output: h) myObject1.incrementCount(); output: i) myObject1.printX(); output: j) myObject1.printCount(); output: k) myObject2.printCount(); output:arrow_forward
- Java Program Fix this Rock, Paper and scissor program so I can upload it to Hypergrade and it can pass all the test cases. Here is the program: import java.util.Random;import java.util.Scanner;public class RockPaperScissors { public static void main(String[] args) { if (args.length != 1) { System.out.println("Please provide a seed as a command line argument."); return; } long seed = Long.parseLong(args[0]); Random random = new Random(seed); Scanner scanner = new Scanner(System.in); System.out.println("Enter 1 for rock, 2 for paper, and 3 for scissors."); do { int computerChoice = random.nextInt(3); int userChoice = getUserChoice(scanner); if (userChoice == -1) { continue; } System.out.println("Your choice: " + choiceToString(userChoice) + ". Computer choice: " + choiceToString(computerChoice) + "."); int result =…arrow_forwardpublic static void main(String [] args){ int num1 = 5, num2 = 10; swap(num1, num2); System.out.println(“num1 is ”+ num1); System.out.println(“num2 is ”+num2);} public static void swap(int a, int b){ temp = a; a = b; b = temp;} What is the output of the main method?arrow_forwardPlease help debug this: Debugging Exercise 4-3, Farrell, Joyce, Java Programming, 9th edition, Cengage Learning public class DebugBox { private int width; private int length; private int height; private FixDebugBox() { length = 1; width = 1; height = 1; } public DebugBox(int width, int length, int height) { width = width; length = length; height = height; } public void showData() { System.out.println("Width: " + width + " Length: " + length + " Height: " + height); } public double getVolume() { double vol = length - width - height; return vol; } }arrow_forward
- What gets printed when the following program is compiled and run? class xyz { public static void main(String args[]) { int i,j,k; for (i = 0; i < 3; i++) { for(j=1; j < 4; j++) { for(k=2; k<5; k++) { if((i == j) && (j==k)) System.out.println(i); }}}}} a: 0 b: 1 c: 2 d: 3arrow_forwardJAVA Determine the output for the following code public class Beta extends Baap { public int h = 44; public int getH( ) { System.out.println("Beta " + h); return h; } public static void main(String[ ] args) { Baap b = new Beta(); System.out.println(b.h + " " + b.getH( )); Beta bb = (Beta) b; System.out.println(bb.h + " " + bb.getH( )); } } public class Baap { public int h = 4; public int getH( ) { System.out.println("Baap " + h); return h; } }arrow_forwardCorrect my codes in java //Stringimport java.util.Scanner;class salary{double multiply(double month,int day){double salary=month*day;return salary;}String schoole (String teacher1,String teacher2){String manger=teacher1+teacher2;return manger;}}public class Assignment2 {public static void main(String args[]){salary obj=new salary();Scanner sc=new Scanner (System.in);System.out.println();double month=sc.nextDouble();int day=sc.nextInt();String teacher1=sc.next();String teacher2=sc.next();double salary=obj.salary(month,day);String schoole=obj.schoole(teacher1,teacher2);String manger;System.out.println("manger"+manger);System.out.println("salary"+salary);}}arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT