About Question enthuware.ocpjp.i.v11.2.1311 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
lucasbeer
Posts: 1
Joined: Fri Jun 26, 2020 3:59 am
Contact:

About Question enthuware.ocpjp.i.v11.2.1311 :

Post by lucasbeer »

A NullPointerException never occurs because the index expression must be completely evaluated before any part of the indexing operation occurs, and that includes the check as to whether the value of the left-hand operand is null.
Could someone please explain this to me in clearer terms?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.1311 :

Post by admin »

While evaluating the expression a [ m1() ];, the JVM has to invoke the method m1() first. But the call to m1 throws Exception. So, before the JVM could access any element of a (which is null), it gets the Exception thrown from the call to m1. So, there is no NullPointerException.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 47 guests