Question: Java Test 31) How many times are the following loops executed? for (int i = 0; i < 10; i++) for (int j = 0;
Java Test
31) How many times are the following loops executed? for (int i = 0; i < 10; i++) for (int j = 0; j < i; j++) System.out.println(i * j)
31) A) 100 B) 10 C) 20 D) 45 6
32) Analyze the following code. public class Test { public static void main(String[ ] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); } }
32) A) The program runs and prints 2 once. B) The program runs and prints 2 twice. C) The program has a compile error because the two methods m have the same signature. D) The program has a compile error because the second m method is defined, but not invoked in the main method.
33) Which of the following is the best for generating random integer 0 or 1?
33) A) (int)Math.random() B) (int)(Math.random() + 0.2) C) (int)(Math.random() + 0.8) D) (int)Math.random() + 1 E) (int)(Math.random() + 0.5) 3
34) Variables that are shared by every instances of a class are ________.
34) A) private variables B) class variables C) instance variables D) public variables
35) Which of the following operators are right-associative?
35) A) + B) % C) * D) = E) &&
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
