Computer Science · Java Programming
निम्नलिखित जावा (Java) प्रोग्राम का आउटपुट क्या होगा? class CustomException extends Exception { public CustomException(String message) { super(message); } } public class TestCustomException { public static void main(String[] args) { try { validateAge(15); } catch (CustomException e) { System.out.println('Caught Exception: ' + e.getMessage()); } finally { System.out.println('Execution finished.'); } } public static void validateAge(int age) throws CustomException { if (age < 18) { throw new CustomException('Age must be 18 or above.'); } System.out.println('Age is valid.'); } }
- 1Caught Exception: null Execution finished.
- 2Caught Exception: Age must be 18 or above. Execution finished.✓
- 3Age is valid. Execution finished.
- 4कंपाइलेशन एरर क्योंकि कस्टम अपवाद (custom exceptions) Exception क्लास को विस्तारित नहीं कर सकते।
सही उत्तर देखें
Caught Exception: Age must be 18 or above. Execution finished.
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Java Programming?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Java Programming