Computer Science  >  QUESTIONS & ANSWERS  >  UNIT_17_TEST.docx. Coding criteeria. Accurate programs. Download to score A (All)

UNIT_17_TEST.docx. Coding criteeria. Accurate programs. Download to score A

Document Content and Description Below

Which of the following code segments could fill /* blank */ so the code would add the first and third element of list? ArrayList<Object> list = new ArrayList<Object>(); list.add(5); list.add("abc" ... ); list.add(4); list.add(1.2); list.add('a'); list.add("10"); int i = /* blank */ a. list.get(0) + list.get(2); b. list.get(1) + list.get(3); c. (int)(list.get(0)) + (int)(list.get(2)); d. (int)list.get(0) + (int)list.get(2); e. more than one of these 2. What is output by the code below? String[] ray; ray = new String[4]; ray[1] = "one"; ray[2] = "two"; ray[3] = "three"; ray[0] = ray[2]; ray[2] = null; System.out.println( ray[0] ); a. one b. two c. three d. null e. 0 © A+ Computer Science – www.apluscompsci.com © A+ Computer Science – www.apluscompsci.com 3. Which of the descriptions provided below describes the best way to improve the code shown below to ensure that all of the occurrences of string one will be removed? public static void removeAllOnes(ArrayList<String> all) { int spot = all.size() - 1; while ( spot > 0 ) { if( all.get(spot).equals("one") ) all.remove(spot); spot--; } } a. Change the while loop to a for loop. b. Change the while loop to an in if statement. c. Add an else before spot-- in the loop. d. Change the while loop condition to ( spot >= 0 ) e. Change spot-- to spot++. 4. What is output by the code below? List<String> bigList = new ArrayList<String>(); bigList.add(0,"one"); bigList.add("two"); bigList.add(0,"three"); bigList.add("four"); bigList.add(0,"five"); bigList.set(2,"six"); bigList.set(3,"seven"); out.println( bigList.indexOf("three") ); a. 2 b. 1 c. 0 d. 4 e. 5 © A+ Computer Science – www.apluscompsci.com © A+ Computer Science – www.apluscompsci.com 5. What is output by the code below? List<String> badList = new ArrayList<String>(); badList.add(0,"one"); badList.add("two"); badList.set(0,"three"); badList.add(1,"four"); badList.set(1,"five"); out.println( badList.get(0) ); a. one b. two c. three d. four e. five 6. What is output by the code below? List<String> list = new ArrayList<String>(); list.add("one"); list.add(0,"two"); list.set(0,"three"); list.add(1,"four"); list.set(2,"five"); System.out.println(list [Show More]

Last updated: 3 years ago

Preview 1 out of 33 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of UNIT_17_TEST.docx. Coding criteeria. Accurate programs. Download to score A document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$13.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

59
0

Document information


Connected school, study & course


About the document


Uploaded On

Feb 23, 2022

Number of pages

33

Written in

All

Seller


Profile illustration for SupremeDocs
SupremeDocs

Member since 3 years

25 Documents Sold

Reviews Received
1
0
0
1
1
Additional information

This document has been written for:

Uploaded

Feb 23, 2022

Downloads

 0

Views

 59

Document Keyword Tags


$13.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, and live chat.
 FAQ
 Questions? Leave a message!


Copyright © Scholarfriends · High quality services·