exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 132 discussion

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

Given the code fragment:

What is the result?

  • A. Compilation fails.
  • B. Hi removed
  • C. An UnsupportedOperationException is thrown at runtime.
  • D. The program compiles, but it prints nothing.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
dsms
5 months, 3 weeks ago
Selected Answer: A
Correct answer is: Compile error 1. List<String> arrList = new ArrayList<>(Arrays.asList(arr); the ) is absent. It must be (Arrays.asList(arr)) 2. System.out.println(s+ "removed"); // s cannot be resolved to a variable
upvoted 1 times
...
akbiyik
1 year, 2 months ago
Compile error because s scoop is only in predicate scoop
upvoted 2 times
...
UAK94
1 year, 3 months ago
Answer is A. String [] arr = {"Hi", "How", "Are", "You"}; List<String> arrList = new ArrayList<>(Arrays.asList(arr)); if (arrList.removeIf( (String s) -> {return s.length() <= 2;})) { System.out.println(arrList); // [How, Are, You] System.out.println(s+ "removed"); // s cannot be resolved to a variable }
upvoted 1 times
...
iSnover
1 year, 3 months ago
Selected Answer: A
The answer is the letter A, in the third line of code there is no last ")" to close the Array's asList method.
upvoted 2 times
...
Tarik2190
2 years, 11 months ago
Answer is A: import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Test { static int a1; public static void doProduct(Integer a){ a1 = a * a; } public static void doString(StringBuilder s) { s.append(" " + s); } public static void main(String[] args) { String [] arr = {"Hi", "How", "Are", "You"}; List<String> arrList = new ArrayList<>(Arrays.asList(arr)); if (arrList.removeIf((String s) -> {return s.length() <= 2;})) { System.out.println(s + "removed"); } } }
upvoted 3 times
...
hackGh
3 years, 2 months ago
System.out.println(s +"removed"); s make compile error because s scoop only in predicate scoop
upvoted 4 times
...
Harid
3 years, 5 months ago
The correct answer is A variable "s" inside println statement is out of scope --> unreachable, causes Compile error Note: comment out println, code compiles and "Hi" is removed.
upvoted 3 times
...
massigirello
3 years, 5 months ago
If you add the bracket (and the semicolon) and remove the System.out of "s" the code compiles fine. I 've tried to print the list and it works. The size change so you can remove elements
upvoted 1 times
...
[Removed]
3 years, 6 months ago
It used lambda function and a lambda function needs to have the bracket for the return part
upvoted 2 times
...
SamAru
3 years, 7 months ago
Agreed
upvoted 1 times
...
hemassridhar
3 years, 11 months ago
Correct, variable 's' in print statement is not visible. If there is no compilation error, then UnSupportedOperation Exception will be thrown as we cannot remove elements from Array backed List.
upvoted 4 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