Java Test 4 β Medium Level Welcome to your Java Test 4 β Medium Level1. What does the following code print?int x = 3;int y = 4;System.out.println(x * y + y); A) 21 B) 16 C) 15 D) 12 None 2. Which of the following keywords is used to inherit from a class? A) implements B) this C) extends D) super None 3. What will this code print?for (int i = 0; i < 3; i++) {Β Β Β System.out.print(i + " ");} A) 1 2 3 B) 0 1 2 C) 0 1 2 3 D) 3 2 1 None 4. What is the output of this code?boolean a = true;boolean b = false;System.out.println(a && b); A) true B) false C) a && b D) Error None 5. What does this code print?int a = 2;int b = 5;if (a > b) {Β Β System.out.println("A");} else {Β Β System.out.println("B");} A) A B) a C) B D) Error None 6. What is printed by this code?String s = "abc";System.out.println(s.indexOf("b")); A) 1 B) 0 C) 2 D) -1 None 7. What is a constructor in Java? A) A special method used to create objects B) A method that destroys objects C) A method that returns a value D) A static method None 8. What will this code print?int[] numbers = {10, 20, 30};System.out.println(numbers[1]); A) 10 B) 30 C) 20 D) 1 None 9. What is the output of this code?String s = "Java";System.out.println(s.equals("java")); A) true B) "Java" C) Error D) false None 10. What happens if you try to access an index outside the array bounds? A) Returns null B) Wraps around C) Throws an ArrayIndexOutOfBoundsException D) Gives a warning but runs None Time's upDid you like it? Donβt keep it to yourself β share it like juicy gossip! π