What will the following program print when compiled and run? Select the two correct answers. (a) (1)
Question:
What will the following program print when compiled and run?
Select the two correct answers.
(a) (1) will print [Anna, Ada, Bob, null].
(b) (1) will print [Anna, adA, Bob, null].
(c) (2) will print [Anna, Ada, Bob].
(d) (2) will print [Bob, Ada, Anna].
(e) The program will throw an IndexOutOfBoundsException at runtime.
Transcribed Image Text:
import java.util.ArrayList; import java.util.List; public class RQ12A15 ( public static void main(String[] args) { doItl (); doIt2 (); } public static void doItl () { List sbListone = new ArrayList (); sbListOne.add(new StringBuilder ("Anna")); sbList One.add(new StringBuilder ("Ada")); sbListOne.add (new StringBuilder ("Bob")); List sbList Two new ArrayList (sbListOne); sbListOne.add(null); (1) } } (2) sbListTwo.get (1).reverse(); System.out.println (sbListOne); public static void doIt2 () { List listone = new ArrayList (); listOne.add ("Anna"); listOne.add("Ada"); listOne.add("Bob"); List listTwo = new ArrayList (listOne); String strTemp = listOne.get (0); listone. set (0, listOne.get (listOne.size () -1)); listOne. set (listOne.size ()-1, strTemp); System.out.println (list Two); //
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (1 review)
b and c In the method doIt1 one of the common elements Ada ...View the full answer
Answered By
Michael Owens
I am a competent Software Engineer with sufficient experience in web applications development using the following programming languages:-
HTML5, CSS3, PHP, JAVASCRIPT, TYPESCRIPT AND SQL.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Programmers Guide To Java SE 8 Oracle Certified Associate OCA
ISBN: 9780132930215
1st Edition
Authors: Khalid Mughal, Rolf Rasmussen
Question Posted:
Students also viewed these Computer science questions
-
What will the following program print when compiled and run? Select the one correct answer. (a) The program will not compile. (b) The program will throw an IndexOutOfBoundsException at runtime. (c)...
-
What will the following program print when compiled and run? Select the one correct answer. (a) The program will not compile. (b) The program will throw an IndexOutOfBoundsException at runtime. (c)...
-
What will the following program print when compiled and run? Select the one correct answer. (a) The program will not compile. (b) The program will throw an IndexOutOfBoundsException at runtime. (c)...
-
In Boolean algebra, the bar sign (-) indicates: Select one: a. NOT operation b. AND operation C. OR operation d. All of the mentioned
-
A small, 2.00-g plastic ball is suspended by a 20.0-cm-long string in a uniform electric field as shown in Figure P23.54. If the ball is in equilibrium when the string makes a 15.0° angle with...
-
Tyrell Company issued callable bonds with a par value of $10,000. The call option requires Tyrell to pay a call premium of$500 plus par (or a total of $10,500) to bondholders to retire the bonds. On...
-
Sarah has asked for help in determining whether she should receive her $25,000 bonus check in the current year or next year. In the current year, her marginal tax rate is 24% and she anticipates she...
-
Ivy Enterprises Inc. manufactures bathroom fixtures. The stockholders equity accounts of Ivy Enterprises Inc., with balances on January 1, 2010, are as follows: The following selected transactions...
-
1. The endpoints of the bottom side of a parallelogram are at A(2, 1) and B(10, 7). The other two sides both have slope 3, and length 5 cm. (a) (2 points) Provide a very neat and accurate sketch this...
-
What will the following program print when compiled and run? Select the one correct answer. (a) The program will not compile. (b) The program will throw a NullPointerException at runtime. (c) The...
-
Which statement is true about the java.util.ArrayList class? Select the one correct answer. (a) The method delete() can be used to delete an element at a specific index in an ArrayList. (b) The...
-
If you were an applicant, would the HVP program be attractive to you? Why or why not? If you were going to be an offer receiver, which of the three plans would you choose and why?
-
Begin with a specialized physician and draw a value chain map. List the different influences that impact the specialized physician from both the upstream and downstream value chain.
-
One of the principal benefits of creating a bottom-up estimate during planning is that the estimate: a. can be created quickly b. is very accurate c. matches the high-level estimate in the project...
-
What is an Agile spike, and when would it be used?
-
A large pharmaceutical company wants to ascertain how well it is meeting the needs of its stakeholders. The business development team determines that the key stakeholders it wishes to survey include...
-
What is the purpose of dummy tasks, and on what types of projects would you use them for budgeting purposes?
-
Refer to the 2006 balance sheet for Consolidated Edison, reproduced in Exhibit 3-6 on pages 108110. 1. Compute the following financial ratios for Consolidated Edison for 2006: (a) Debt ratio (total...
-
Air pollution generated by a steel mill is an example of a) a positive production externality. b) a negative production externality. c) a public good. d) the free-rider problem. State and local taxes...
-
Media applications that play audio or video files are part of a class of workloads called streaming workloads; i.e., they bring in large amounts of data but do not reuse much of it. Consider a video...
-
What decimal number does the bit pattern 00C000000 represent if it is a twos complement integer? An unsigned integer?
-
If the bit pattern 00C000000 is placed into the Instruction Register, what MIPS instruction will be executed?
-
Facts: International shoe manufactured footwear in Missouri, but sold its products nationwide. International shoe did not have warehouses in Washington State, but it did send a dozen salespeople...
-
Ricarldo's father asks him to go to the drug store to buy a bottle of Panadol. Ricarldo had a long day at school, is tired, and does not want to leave the house. Sensing this, his father offers to...
-
Why use a research process? Because in practice, accounting researchers actually apply a similar process, Because researchers who do not use a research process often have to make several...
Study smarter with the SolutionInn App