Which of the following statements is correct about constants?
Blog
Assuming that the user provides 49 as input, what is the out…
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);
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?
What is the output of the statements below? int a = 10; int…
What is the output of the statements below? int a = 10; int b = 20; int count = 0; if (a > 5) if (b > 5) { count ++; } else count = 7; System.out.print (count);
Suppose you want to write an if statement with multiple alte…
Suppose you want to write an if statement with multiple alternatives to print out someone’s tax bracket based on their income. Assume the integer variable income holds the annual income. What is wrong with the following if statement? if (income < 10000) { System.out.println("Lowest tax bracket"); } if (income < 20000) { System.out.println("Low-Middle tax bracket"); } if (income < 30000) { System.out.println("Middle tax bracket"); } System.out.println("High tax bracket");
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?
Which of the following for loops is illegal?
Which of the following for loops is illegal?
Which of the following conditions will correctly check if t…
Which of the following conditions will correctly check if the String variable early comes before “middle” alphabetically?
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?
When an array reading and storing input runs out of space
When an array reading and storing input runs out of space