Start learning 50% faster. Sign in now
In Java, a single try block can handle multiple exceptions by attaching multiple catch blocks. Each catch block specifies a distinct exception type. The exception hierarchy determines the order of catch blocks—child exceptions must precede parent exceptions. Example: try { int a = 5 / 0; // ArithmeticException int[] arr = new int[2]; System.out.println(arr[3]); // ArrayIndexOutOfBoundsException } catch (ArithmeticException e) { System.out.println("Arithmetic Exception caught"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Array Index Out of Bounds Exception caught"); } catch (Exception e) { System.out.println("Generic Exception caught"); } ________________________________________ Why Other Options Are Incorrect: 1. Separate try blocks for each exception: This is inefficient and makes code less readable. A single try block with multiple catch blocks is the recommended approach. 2. Nesting try blocks within each other: This is not a standard practice unless the logic explicitly demands it. It can lead to convoluted and hard-to-maintain code. 3. Single catch block for all exceptions: While possible, this is a poor practice as it does not differentiate exception types, leading to less precise error handling. 4. Writing the exception type as a string: Java’s catch block requires exception classes, not strings, for type checking.
Delicensing means abolishing the requirement of an industrial license to
(i) set up a new unit
(ii) substantially expand an existing ...
Which of the following given options would result in increase in gross external debt, ceteris paribus?
पूर्ण प्रतिस्पर्धी बाजारों के लिए निम्नलिखित में से कौन ...
Let Pr (X=2) = 1. Define µ2n = E(X-µ)^2n, µ= E(X). Then:
Market Stabilization Scheme (MSS) was launched by the RBI in_______.
_________ may be defined as a situation in which the poor are unable to accumulate resources or earn enough to move out of the vicious cycle of poverty.
Which of the given options is INCORRECT in the context of fiscal deficit?
What is constant along an isoquant?
When the demand curve is a horizontal straight line, it indicates that the price elasticity of demand is_______.
Which of the following is NOT one of the recognised systems of medicines under AYUSH?