About Question enthuware.ocajp.i.v7.2.1246 :
Moderator: admin
-
- Posts: 13
- Joined: Mon Jun 16, 2014 1:07 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.1246 :
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?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1246 :
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.
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.
-
- Posts: 38
- Joined: Fri Nov 13, 2015 4:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1246 :
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).
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).
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1246 :
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.
-
- Posts: 38
- Joined: Fri Nov 13, 2015 4:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1246 :
Ah ok, thanks for the clarification.
Who is online
Users browsing this forum: No registered users and 7 guests