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
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.
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
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
...
Log in to ExamTopics
Sign in:
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.
dsms
5 months, 3 weeks agoakbiyik
1 year, 2 months agoUAK94
1 year, 3 months agoiSnover
1 year, 3 months agoTarik2190
2 years, 11 months agohackGh
3 years, 2 months agoHarid
3 years, 5 months agomassigirello
3 years, 5 months ago[Removed]
3 years, 6 months agoSamAru
3 years, 7 months agohemassridhar
3 years, 11 months ago