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);
}
}
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
Starting Out with Java: Early Objects (6th Edition)
Starting Out with Python (4th Edition)
Programming in C
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java How To Program (Early Objects)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- 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
- 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