exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 153 discussion

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

Given the code fragment:

What is the result?

  • A. Compilation fails.
  • B. The program compiles, but it prints nothing.
  • C. HiHowAreYou removed
  • D. An UnsupportedOperationException is thrown at runtime.
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
DriftKing
3 months, 3 weeks ago
Selected Answer: C
C. HiHowAreYou removed System.out.print(s) will print all the elements in array list and return s.length() <=2 will return string that has string size less than or equal to 2 which is "Hi". So removeif predicate will remove Hi from the array list and "if" condition will become true. Code- import java.util.*; public class Test { public static void main(String[] args) { String[] arr = {"Hi", "How", "Are", "You"}; List<String> arrList = new ArrayList<>(Arrays.asList(arr)); if (arrList.removeIf(s -> { System.out.print(s); return s.length() <=2;})) { // System.out.println(arrList); //you can uncomment this print statement to see Hi getting //removed from arraylist. System.out.println(" removed"); } } }
upvoted 3 times
...
akbiyik
1 year, 1 month ago
Selected Answer: C
The correct answer is C
upvoted 1 times
...
iSnover
1 year, 3 months ago
Selected Answer: C
A resposta correta é a letra C, eu testei e segue o código: public static void main(String[] args) { String[] arr = {"Hi", "How", "Are", "You"}; List<String> arrList = new ArrayList<>(Arrays.asList(arr)); if (arrList.removeIf(s -> { System.out.print(s); return s.length() <=2;})) { System.out.println(" removed"); } }
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