Assuming that the user provides 49 as input, what is the output of the following code snippet? int x = 0; int y = 0; System.out.print(“Please enter y: “); Scanner in = new Scanner(System.in); y = in.nextInt(); if (y > 50); { x = y; } System.out.println(“x: ” + x);
Blog
The two strings “Aardvark” and “Aardvandermeer” are exactly…
The two strings “Aardvark” and “Aardvandermeer” are exactly the same up to the first six letters. What is their correct lexicographical ordering?
What is the output of the following code snippet? int[] valu…
What is the output of the following code snippet? int[] values = { 1, 2, 3, 4}; values[2] = 24; values[values[0]] = 86; for (int i = 0; i < values.length; i++) { System.out.print (values[i] + " "); }
Assume the method doSomething has been defined as follows: p…
Assume the method doSomething has been defined as follows: public static void doSomething (int[] values, int p1, int p2) { int temp = values[p1]; values[p1] = values[p2]; values[p2] = temp; } What does the method do?
Which of the following for loops is illegal?
Which of the following for loops is illegal?
Which one of the following types of statements is an instruc…
Which one of the following types of statements is an instruction to set the value of a variable?
When an array reading and storing input runs out of space
When an array reading and storing input runs out of space
Consider the following code snippet in Java 6 or later: Stri…
Consider the following code snippet in Java 6 or later: String[] data = { “abc”, “def”, “ghi”, “jkl” }; String[] data2 = Arrays.copyOf(data, data.length – 1); What does the last element of data2 contain?
What will be printed by the statements below? int[] values =…
What will be printed by the statements below? int[] values = { 10, 24, 3, 64}; int position = 0; for (int i = 1; i < values.length; i++) { if (values[i] > values[position]) { position = i; } } System.out.print (position);
Assume the method createSomething has been defined as follow…
Assume the method createSomething has been defined as follows: public static int [] createSomething (int start, int size) { int [] result = new int[size]; for (int i = 0; i < result.length; i++) { result[i] = start; start++; } return result; } What is printed by the statement below? System.out.print(Arrays.toString(createSomething(4, 3)));