exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 49 discussion

Actual exam question from Oracle's 1z0-808
Question #: 49
Topic #: 1
[All 1z0-808 Questions]

Given the code fragment:

What is the result?

  • A. true true
  • B. true false
  • C. false false
  • D. false true
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
letmein2
Highly Voted 5 years, 6 months ago
Correct. Classic trap. str.trim() did not assign back to str. There was no effect.
upvoted 15 times
...
v323rs
Highly Voted 4 years, 11 months ago
correct answer C. false false
upvoted 5 times
...
MPignaProTech
Most Recent 2 months ago
Selected Answer: C
" " returne false, C is the correct answer
upvoted 1 times
...
Kolodets
1 year, 7 months ago
C. Whitespace is content => isEmpty() returns false
upvoted 2 times
...
Vicky_65
1 year, 8 months ago
Selected Answer: C
C is right.Because String is with the one space and it will not executes true for both conditions.
upvoted 1 times
...
odzio33
1 year, 11 months ago
Selected Answer: C
String str2 = " "; str2.trim(); // if we use str2 = str2.trim(); the answer will be true true System.out.println(str2.equals("") + " " + str2.isEmpty()); The trim() method in Java String is a built-in function that eliminates leading and trailing space Answer is C false false
upvoted 2 times
...
Ripfumelo
1 year, 11 months ago
--- exec-maven-plugin:3.0.0:exec (default-cli) @ mavenproject40 --- true true ------------------------------------------------------------------------ BUILD SUCCESS ------------------------------------------------------------------------ Total time: 0.823 s Finished at: 2023-01-06T14:42:05+02:00
upvoted 1 times
...
RoxyFoxy
2 years, 3 months ago
Selected Answer: C
Correct answer C because String is immutable so it can't be changed. Here trim() has no effect on str. If we had: "str = str.trim();" the correct answer would have been true true.
upvoted 2 times
...
XalaGyan
2 years, 10 months ago
Selected Answer: C
C is correct
upvoted 2 times
...
Raju15
3 years, 9 months ago
Correct Answer is C. Tested. Make sure you assign String str = " "; (Space in between double quotes) when you test the code.
upvoted 1 times
...
Ayla
4 years, 1 month ago
A is correct
upvoted 1 times
...
pillu2012
4 years, 3 months ago
A is correct! tested
upvoted 1 times
hcampos
4 years, 3 months ago
C is correct. You should try the following code. public static void main(String[] args) { String str = ""; str.trim (); System.out.println (str.equals ("") + "" + str.isEmpty ()); }
upvoted 1 times
tamanna786
4 years, 2 months ago
it is false false. there is a space between to double quotes .
upvoted 1 times
...
...
...
pillu2012
4 years, 3 months ago
B is right
upvoted 1 times
hcampos
4 years, 3 months ago
B is wrong because str.trim () returns a new string instance. In the end, str continues with the original value.
upvoted 1 times
atlassi708
4 years, 1 month ago
not a new string instance but put an empty string in the string pool but the main cause is that String is an immutable class
upvoted 3 times
...
...
...
M_Jawad
4 years, 11 months ago
correct
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago