Oracle
1Z0-851 · Question #105
Given: public static void main(String[] args) { try { args = null; args[0] = "test"; System.out.println(args[0]); } catch (Exception ex) { System.out.println("Exception"); } catch…
The correct answer is C. Compilation fails. See the full explanation below for the reasoning.
Question
Given: public static void main(String[] args) { try { args = null; args[0] = "test"; System.out.println(args[0]); } catch (Exception ex) { System.out.println("Exception"); } catch (NullPointerException npe) { System.out.println("NullPointerException"); } } What is the result?
Options
- Atest
- BException
- CCompilation fails.
- DNullPointerException
How the community answered
(19 responses)- A5% (1)
- B11% (2)
- C74% (14)
- D11% (2)
Community Discussion
No community discussion yet for this question.