Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5, Problem 4AW
What will the following
public class ChangeParam
{
public static void main(String[] args)
{
int x = 1;
double y = 3.4;
System.out.println(x + “ ” + y);
changeUs(x, y);
System.out.printing (x + “ ” + y);
}
public static void changeUs(int a, double b)
{
a = 0;
b = 0.0;
System.out.println(a + ” ” + b);
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What will happen when you compile and run the following code? #1. public class Test{
public static void main(String[] args){
int a = 10, b = 0;
while( a + 2 < 10 || b - 2 > 0){
System.out.println(a);
}
}
}
#2. public class Test{
public static void main(String[] args){
int a = 0, b = 10;
while(b - 40 > 0){
b -= 2;
while(a + 12 < 10){
a += 2;
if(a == b)
continue;
System.out.print(a + " " + b + ", ");
}
}
}
}
show the output and solution, its java language
What will the following program display?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);}}
What will the following program display?public class Checkpoint{public static void main(String[] args){int a = 10;decrementNum(a);}public static void decrementNum (int n){if (n > 0)DecrementNum (n - 2);elseSystem.out.println(n); }}
Chapter 5 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 5.1 - Prob. 5.1CPCh. 5.1 - Prob. 5.2CPCh. 5.1 - Prob. 5.3CPCh. 5.1 - What message will the following program display if...Ch. 5.1 - Prob. 5.5CPCh. 5.2 - What is the difference between an argument and a...Ch. 5.2 - Prob. 5.7CPCh. 5.2 - Prob. 5.8CPCh. 5.2 - Prob. 5.9CPCh. 5.2 - What will the following program display? public...
Ch. 5.4 - Prob. 5.11CPCh. 5.4 - Prob. 5.12CPCh. 5.4 - Prob. 5.13CPCh. 5.4 - Prob. 5.14CPCh. 5 - Prob. 1MCCh. 5 - Prob. 2MCCh. 5 - Prob. 3MCCh. 5 - Prob. 4MCCh. 5 - A value that is passed into a method when it is...Ch. 5 - Prob. 6MCCh. 5 - Prob. 7MCCh. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - True or False: You terminate a method header with...Ch. 5 - Prob. 11TFCh. 5 - Prob. 12TFCh. 5 - Prob. 13TFCh. 5 - Prob. 14TFCh. 5 - Prob. 15TFCh. 5 - Prob. 16TFCh. 5 - Prob. 17TFCh. 5 - True or False: No two methods in the same program...Ch. 5 - True or False: It is possible for one method to...Ch. 5 - True or False: You must have a return statement in...Ch. 5 - Prob. 1FTECh. 5 - Look at the following method header: public static...Ch. 5 - Prob. 3FTECh. 5 - Prob. 4FTECh. 5 - Prob. 1AWCh. 5 - Here is the code for the displayValue method,...Ch. 5 - Prob. 3AWCh. 5 - What will the following program display? public...Ch. 5 - A program contains the following method...Ch. 5 - Prob. 6AWCh. 5 - Prob. 7AWCh. 5 - Write a method named square that accepts an...Ch. 5 - Write a method named getName that prompts the user...Ch. 5 - Write a method named quartersToDol1ars. The method...Ch. 5 - Prob. 1SACh. 5 - Prob. 2SACh. 5 - What is the difference between an argument and a...Ch. 5 - Where do you declare a parameter variable?Ch. 5 - Prob. 5SACh. 5 - Prob. 6SACh. 5 - Prob. 1PCCh. 5 - Retail Price Calculator Write a program that asks...Ch. 5 - Rectangle AreaComplete the Program If you have...Ch. 5 - Paint Job Estimator A painting company has...Ch. 5 - Prob. 5PCCh. 5 - Celsius Temperature Table The formula for...Ch. 5 - Test Average and Grade Write a program that asks...Ch. 5 - Conversion Program Write a program that asks the...Ch. 5 - Distance TraveLed Modification The distance a...Ch. 5 - Stock Profit The profit from the sale of a stock...Ch. 5 - Multiple Stock Sales Use the method that you wrote...Ch. 5 - Kinetic Energy In physics, an object that is in...Ch. 5 - isPrime Method A prime number is a number that is...Ch. 5 - Prime Number List Use the isPrime method that you...Ch. 5 - Even/Odd Counter You can use the following logic...Ch. 5 - Present Value Suppose you want to deposit a...Ch. 5 - Rock, Paper, Scissors Game Write a program that...Ch. 5 - ESP Game Write a program that tests your ESP...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What are the two modes that a random access file may be opened in? Explain the difference between them.
Starting Out with Java: From Control Structures through Objects (6th Edition)
Word Separator Write a program that accepts as input a sentence in which all of the words are run together, but...
Starting Out with C++: Early Objects
What output is produced by the following code? (Assume a proper import
statement has been given.)
Absolute Java (6th Edition)
A derived class inherits the _____ of its base class.
Starting Out with C++: Early Objects (9th Edition)
What is the difference between a class and an object?
Computer Science: An Overview (12th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Give the output of the following program public class QuizProblem { public static String quizProb(int i, int j, String myString) { String answer = ""; if(i > j) { return answer; } else { return quizProb(i+1,j,myString) + myString.charAt(i); } } public static void main(String[] args) { String testStr="marshall"; System.out.println(quizProb(0,testStr.length()-1,"marshall")); } }arrow_forwardPROGRAM SIMULATION. Understand the given JAVA program and write the output. b. public class ChangeIt { public void doIt( int[] z ) { z[0] = 0; } } public class TestIt { public static void main ( String[] args ) { int[] myArray = {1, 2, 3, 4, 5} ; ChangeIt.doIt(myArray ); for (int j=0; j<myArray.length; j++ ) System.out.print( myArray[j] + " " ) ; } }arrow_forwardWhat is the printout of the following code? public class Test { public static void main(string[] args) { int[][] matrix = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}}; for (int i = 0; i < 4; i++) System.out.print(matrix[1][i] + " "); }}arrow_forward
- What will be the output of the following Java code? class average { public static void main(String args[]) { double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5}; double result; result = 0; for (int i = 0; i < 6; ++i) result = result + num[i]; System.out.print(result/6); } } a) 16.34 b) 16.566666644 c) 16.46666666666667 d) 16.46666666666666arrow_forwardIn Java trace the table for the do while loop public class Main { public static void main(String[] args) { int x,j,y; /// Question 1 j = 30; x=5; do { j=j-x-2; --x; }while (j > 20); j x j>20arrow_forwardWhat is the output of the following Java program? class Test { public static void main (String args[]) { for(int i=0; 0; i++) { System.out.println("Hello World"); } } } Hello World 0, 1, 2, 3 0, 1, 2, 3, 4 Compile-time error because the for loop demands a boolean value in the second partarrow_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_forwardChange Java code below so that it outputs a 9x9 board and not a 3x3 board. import java.util.*; public class Tic_Tac_Toe{ static String[] board;static String turn;static String checkWinner(){for (int a = 0; a < 8; a++) {String line = null; switch (a) {case 0:line = board[0] + board[1] + board[2];break;case 1:line = board[3] + board[4] + board[5];break;case 2:line = board[6] + board[7] + board[8];break;case 3:line = board[0] + board[3] + board[6];break;case 4:line = board[1] + board[4] + board[7];break;case 5:line = board[2] + board[5] + board[8];break;case 6:line = board[0] + board[4] + board[8];break;case 7:line = board[2] + board[4] + board[6];break;}//For X winnerif (line.equals("XXX")) {return "X";} // For O winnerelse if (line.equals("OOO")) {return "O";}} for (int a = 0; a < 9; a++) {if (Arrays.asList(board).contains(String.valueOf(a + 1))) {break;}else if (a == 8) {return "draw";}} // To enter the X Or O at the exact place on board.System.out.println(turn + "'s turn; enter…arrow_forwardIn Java trace the table for a while loop public class Main { public static void main(String[] args) { // Question 2 j = 30; x=5; for (int i=1;i<=2;i++) { while (j > 20) { j=j-x*i; ++x; }// end of while }// end of for j x i j<=2 j>20arrow_forward
- 5. What will be the output of following Java program? class Test{public static void main (String[] args){ int arr1[] = {1, 2, 3}; int arr2[] = {1, 2, 3}; if (arr1 == arr2) System.out.println("Same"); else System.out.println("Not same"); }}arrow_forwardWhat will be the output of the following Java program? class Output { public static void main(String args[]) { Double i = new Double(257.5); Double x = i.MAX_VALUE; System.out.print(x); } }arrow_forwardpublic class Turn{public static void main(String[] args){// Different initial values will be used for testingint x = 1; int y = 1; // Turn the arrow by 90 degrees System.out.print("x:", y + 90);System.out.println(x);System.out.print("y: ", x - 1 );System.out.println(y); // Turn the arrow again System.out.print("x:", y - 1);System.out.println(x);System.out.print("y: ",x + 90);System.out.println(y);}}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY