1 - JustAnswer
|1. |
|What is y after the following switch statement? |
|int x = 0; |
|int y = 0; |
|switch (x + 1) { |
| case 0: y = 0; |
| case 1: y = 1; |
| default: y = -1 |
|} |
|[pic]A) 1 |
|[pic]B) -1 |
|[pic]C) 0 |
|[pic]D) None of the above |
| |
|2. |
|Which of the following is a constant, according to Java naming conventions? |
|[pic]A) MAX_VALUE |
|[pic]B) Test |
|[pic]C) read |
|[pic]D) ReadInt |
| |
|3. |
|Analyze the following code: |
|double sum = 0; |
|for (double d = 0; d < 10; sum += sum + d) { |
| d += 0.1; |
|} |
| |
|[pic]A) The program has a syntax error because the adjustment statement is incorrect in the for loop. |
|[pic]B) The program has a syntax error because the control variable in the for loop cannot be of the double type. |
|[pic]C) The program compiles but does not stop because d would always be less than 10. |
|[pic]D) The program compiles and runs fine. |
| |
| |
| |
|4. |
|Which array initialization is correct? |
|[pic]A) int[ ] = new x int = {8, 7, 6, 5, 4}; |
|[pic]B) int[ ] x = {8, 7, 6, 5, 4}; |
|[pic]C) int x[4] = {8, 7, 6,}; |
|[pic]D) const int SIZE = 4; Int x[SIZE]; |
|[pic]E) const int SIZE = 4; int x[SIZE-4]; |
| |
|5. |
|What is k after invoking nPrint("a message", k+1)? |
|xMethod{ |
| int k=2; |
| nPrint("A message", k+1); |
|} |
| |
|nPrint(String message, int n){ |
| while( n>0){ |
| System.out.print(message); |
| n--; |
| } |
|} |
|[pic]A) -1 |
|[pic]B) 0 |
|[pic]C) 1 |
|[pic]D) 2 |
| |
|6. |
|Which of the following outputs values from a 2-D array? |
|[pic]A) |
|for (row = 0; row < 5; row++){ |
|for (col = 0; col < 4; col++){ |
| JOptionPane.showMessageDialog(null, table[row][column]); |
| } |
|} |
| |
|[pic]B) |
|for (row = 5; row < 0; row++){ |
| for (col = 0; col < 4; col++){ |
| JOptionPane.showMessageDialog(null, table[row}[column]); |
| } |
| |
|[pic]C) |
|for (row = 0; row < 5; row++){ |
| for (col = 0; col < 0; col++) |
| JOptionPane.showMessageDialog(null, table[row}[column]); |
|} |
| |
|[pic]D) |
|for (row = 0; row < 5; row++) |
| for (col = 0; col < 4; col++) |
| JOptionPane.showMessageDialog(null, table[row}[column]); |
| |
| |
|7. |
|Given the following statement: |
|int[ ] list = new int[10]; |
| |
|list.length has the value |
|[pic]A) 10 |
|[pic]B) 9 |
|[pic]C) The value depends on how many integers are stored in list. |
|[pic]D) None of the above |
| |
|8. |
|To declare a constant PI, you write |
|[pic]A) final static PI = 3.14159; |
|[pic]B) final float PI = 3.14159; |
|[pic]C) static double PI = 3.14159; |
|[pic]D) final double PI = 3.14159; |
| |
|9. |
|Which of the following is a possible output for 50 * Math.random()? |
|[pic]A) 0 |
|[pic]B) 50 |
|[pic]C) 100 |
|[pic]D) a and b. |
| |
| |
| |
| |
| |
| |
| |
|10. |
|Which one of the following assigns the index value to an array of 10 numbers |
|[pic]A) for (i=0;i ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.