- Aouter
- Binner
- Cboth a and b
- Dnone of these
void test(int a, int b) and void test(double a, double b)void test(int a, double b) and void test(double a, int b)void test(int a, double b) and void test(int a)void test(int a) and int test(int a)
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
both a and b
When the "break" statement is executed within the outer loop, then the outer loop will stop.
public class BreakOuterLoopExample { public static void main(String[] args) { // Outer loop for (int i = 1; i <= 3; i++) { System.out.println("Outer loop iteration: " + i); // Inner loop for (int j = 1; j <= 2; j++) { System.out.println(" Inner loop iteration: " + j); if (i == 2 && j == 1) { System.out.println(" Breaking out of the outer loop."); break; // Breaks out of the outer loop } } if (i == 2) { break; // Ensures the outer loop stops after the break in the inner loop } } } }
Output:
Outer loop iteration: 1 Inner loop iteration: 1 Inner loop iteration: 2 Outer loop iteration: 2 Inner loop iteration: 1 Breaking out of the outer loop.
In this example, the break statement inside the inner loop causes the outer loop to stop when i is 2 and j is 1. The outer loop does not continue after this point.
If a 'while loop' is used within a 'while loop', it is called a nested while loop.
Explanation:
arr[-1+2] simplifies to arr[1].
The element at index 1 in the array is 202.
break
Reason — The absence of break statement leads to fall through situation in switch case statement.
boolean
Reason — isLetter() method returns true if the specified character is a letter else, it returns false. Thus, the return data type of isLetter(char) is boolean.
Each double in Java occupies 8 bytes, and the array contains 4 elements.
Total memory occupied = 8 bytes × 4 = 32 bytes
Correct answer: (d) 32
(d) void test(int a) and int test(int a)
Explanation: Method overloading is based on method signatures (method name + parameter list). Return type differences (void vs. int) do not differentiate overloaded methods, leading to a compilation error.
"Java compiled code (byte code) can run on all operating systems"
👉 This is possible because Java code is compiled into bytecode, which runs on the Java Virtual Machine (JVM).
Since JVMs are available on all major OS (Windows, Linux, macOS, etc.), the same bytecode can run anywhere.
✅ Answer: (c) Platform Independent
Checks for equality between the input expression and case labels → ✅ True
Supports floating point constants → ❌ Not allowed
In Java, switch can only work with:
byte, short, char, int
Their wrapper classes (Byte, Short, Character, Integer)
String
enum types
float and double are not allowed.
break is used to exit the switch block → ✅ True
Case labels are unique → ✅ True
✅ Answer: (b) supports floating point constants
The statement that brings the control back to the calling method:
break → exits a loop or switch, but control does not go to the calling method.
System.exit(0) → terminates the entire program.
continue → skips the current iteration of a loop, but stays inside the loop.
return → exits from the current method and returns control to the calling method. ✅
Answer: (d) return