Java Mock Test 3 Java Mock Test 3, 10 QUESTIONS remus2009 published on June 28, 2009 Stacked 1/10 What will be displayed after you try to compile and execute the following code?------int i = 10;if(i) { System.out.println("A");} else { System.out.println("B");} A B Compilation Error Nothing will be displayed 2/10 How do you write an infinite loop? for(;;) { } while (true) { } do { } while (true); 3/10 Which of the following variables are defined correctly? Hint: 3 choices String $; String _; String 12x; String x12; String s#; String h@ppy; String myString#2; 4/10 How many primitive data types are in Java? 5 6 7 8 9 10 12 5/10 Which will be the value of variable y after you compile and execute the following block of code?------public class MyClass { private int x =10; public static void main(String[] args) { int y = x++%5;} 0 2 Compilation Error Runtime Error 6/10 What will be displayed after you try to compile and execute the following code?------public static void main(String[] args) { final String s = "A"; s.concat("B"); System.out.println(s);} Compilation Error Runtime Error A AB B 7/10 How many Constructors has the Character object? 1 2 3 4 8/10 Which of the following statements are true about Math.random() function It generates an int value bigger or equal to 1 and less than 10. It generates an int value bigger or equal to 1 and less than 100 It generates a float value bigger or equal to 0.0 and less than 1.0 None of these 9/10 What will be displayed after you try to compile and execute the following code?------double x = -34.45;System.out.println(Math.floor(x));System.out.println(Math.ceil(x));System.out.println(Math.abs(x)); 35.034.034.0 -34.0-35.034.0 -35.0-34.034.45 -34.0-34.034.45 10/10 Is the String object immutable? Yes No Depends on JRE version