exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 103 discussion

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

Given the code fragment:

What is the result?

  • A. A NullPointerException is thrown at runtime.
  • B. [1, 2, 4]
  • C. [1, 2, 4, null]
  • D. [1, 3, 4, null]
  • E. [1, 3, 4]
  • F. Compilation fails.
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

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
Sreeni_A
5 months, 2 weeks ago
Correct answer : C
upvoted 1 times
Sreeni_A
5 months, 2 weeks ago
Correct answer : E
upvoted 1 times
...
...
Vicky_65
10 months ago
Selected Answer: E
E is correct
upvoted 1 times
...
CreazyyyyGirl
10 months, 4 weeks ago
Selected Answer: E
E is correct
upvoted 2 times
...
Rajeevkuamr
1 year ago
Answer is E. [1,3,4]
upvoted 1 times
...
akbiyik
1 year, 2 months ago
Selected Answer: E
points.remove(null) makes a call to remove(Object). ArrayList class provides two overloaded remove() methods. remove(int index): Accepts the index of the object to be removed remove(Object obj): Accepts the object to be removed
upvoted 2 times
...
carloswork
1 year, 2 months ago
Selected Answer: E
Answer is E. [1,3,4]
upvoted 1 times
...
kkaayyyy
1 year, 3 months ago
Answer is [ 1, 3, 4 ]
upvoted 1 times
...
iSnover
1 year, 4 months ago
The right answer is the letter E, because the number 1 is added in the second line of the list, but the list indexes from 0, so the 1 is in position zero and the removal done in line 7 removes the data in position 1 of the list which is 2. Remembering that you cannot give the NullPointer exception because lists can print null if it is inserted in one of the positions of the list, it would only give NullPointer exception if the list was empty. If you have any doubts, I'll also test the code, feel free: public static void main(String[] args) { ArrayList<Integer> points = new ArrayList<>(); points.add(1); points.add(2); points.add(3); points.add(4); points.add(null); points.remove(1); points.remove(null); System.out.println(points); }
upvoted 2 times
...
praroopgupta
1 year, 4 months ago
Correct answer should be [1,3,4]
upvoted 3 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