About Question enthuware.ocajp.i.v7.2.1246 :

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

Moderator: admin

Post Reply
Brian B
Posts: 13
Joined: Mon Jun 16, 2014 1:07 pm
Contact:

About Question enthuware.ocajp.i.v7.2.1246 :

Post by Brian B »

Wouldn't this technically return nothing? It compiles fine, but when run, the output from the compiler is nothing. Is the question referring to what the return value of trim() method is or the output of the compiler?

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

Re: About Question enthuware.ocajp.i.v7.2.1246 :

Post by admin »

The statement is a method call. So its return value (which is what is asked by the question) will be the value returned by the method.

If you want to print that return value, you can put it in System.out.println(" hello java guru ".trim());

Whether you print it or not, the value is still returned by the call.
HTH,
Paul.

toolforger
Posts: 38
Joined: Fri Nov 13, 2015 4:40 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1246 :

Post by toolforger »

It's the expression that returns a value.
The statement is an expression statement that simply discards the returned value.

While that's not the only view one can take, I do not think it is less correct, so the wording is at least ambiguous.
That's actually fine if the official OCA exam has the same kind of ambiguities; after all, we're taking the mock tests to prepare ourselves for the exam, less for testing our Java abilities (sad as that may be).

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

Re: About Question enthuware.ocajp.i.v7.2.1246 :

Post by admin »

From the exam pov, you will see the terms, line of code, statement, and expression used interchangeably. We haven't seen questions in the exam that require you to differentiate based on the precise meaning of these terms.

toolforger
Posts: 38
Joined: Fri Nov 13, 2015 4:40 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1246 :

Post by toolforger »

Ah ok, thanks for the clarification.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests