Tag Archives: list

Given: (Exhibit) You want to examine the items list it contains an item for which the variable count

Given:You want to examine the items list it contains an item for which the variable count is below zero.Which code fragment at line 1 accomplish this? A. If (items.stream () .allmatch (i -> count < 0) < 0) ) { B. If (items.stream () .anymatch (i -> count < 0) < 0) ) { C. If (items.stream ()… Read More »

Given the code fragment: List&lt;Integer&gt; list = List.of(11,12,13,12,13); Which statement causes a

Given the code fragment:List<Integer> list = List.of(11,12,13,12,13);Which statement causes a compile time error? A. Integer a = Integer.valueOf(list.get(0)); B. Double e = Double.valueOf(list.get(0)); C. int c =list.get(0); D. Double d = list.get(0); E. Integer b = list.get(0); F. double f = list.get(0); Correct Answer: A

A bookstore's sales are represented by a list of Sale objects populated with the name of the customer

A bookstore’s sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased.public class Sale {private String customer;private List<Book> items;// constructor, setters and getters not shown}public class Book {private String name;private double price;// constructor, setters and getters not shown}Given a list of Sale objects, tList, which code fragment… Read More »

Given: (Exhibit) You want to examine the items list it contains an item for which the variable count

Given:You want to examine the items list it contains an item for which the variable count is below zero.Which code fragment at line 1 accomplish this? A. If (items.stream () .filter (i -> count < 0) . findFirst () ) { B. If (items.stream () .allmatch (i -> count < 0) < 0) ) { C. If (items.stream… Read More »

Given: List&lt;String&gt; list1 = new ArrayList&lt;&gt;(); list1.add("A"); list1.add("B"); List list2

Given:List<String> list1 = new ArrayList<>();list1.add(“A”);list1.add(“B”);List list2 = List.copyOf(list1);list2.add(“C”);List<List<String>> list3 = List.of(list1, list2);System.out.println(list3);What is the result? A. [[A, B],[A, B]] B. An exception is thrown at run time. C. [[A, B], [A, B, C]] D. [[A, B, C], [A, B, C]] Correct Answer: B

Given: (Exhibit) You want to examine the items list it contains an item for which the variable count

Given:You want to examine the items list it contains an item for which the variable count is below zero.Which code fragment at line 1 accomplish this? A. If (items.stream () .filter (i -> count < 0) . findFirst () ) { B. If (items.stream () .anymatch (i -> count < 0) < 0) ) { C. If (items.stream… Read More »

Given: List&lt;String&gt; list1 = new ArrayList&lt;&gt;(); list1.add("A"); list1.add("B"); List list2

Given:List<String> list1 = new ArrayList<>();list1.add(“A”);list1.add(“B”);List list2 = List.copyOf(list1);list2.add(“C”);List<List<String>> list3 = List.of(list1, list2);System.out.println(list3);What is the result? A. [[A, B],[A, B]] B. An exception is thrown at run time. C. [[A, B], [A, B, C]] D. [[A, B, C], [A, B, C]] Correct Answer: B

A bookstore's sales are represented by a list of Sale objects populated with the name of the customer

A bookstore’s sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased.public class Sale {private String customer;private List<Book> items;// constructor, setters and getters not shown}public class Book {private String name;private double price;// constructor, setters and getters not shown}Given a list of Sale objects, tList, which code fragment… Read More »

Given: List&lt;String&gt; list1 = new ArrayList&lt;&gt;(); list1.add("A"); list1.add("B"); List list2

Given:List<String> list1 = new ArrayList<>();list1.add(“A”);list1.add(“B”);List list2 = List.copyOf(list1);list2.add(“C”);List<List<String>> list3 = List.of(list1, list2);System.out.println(list3);What is the result? A. [[A, B],[A, B]] B. An exception is thrown at run time. C. [[A, B], [A, B, C]] D. [[A, B, C], [A, B, C]] Correct Answer: B

A bookstore's sales are represented by a list of Sale objects populated with the name of the customer

A bookstore’s sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased.public class Sale {private String customer;private List<Book> items;// constructor, setters and getters not shown}public class Book {private String name;private double price;// constructor, setters and getters not shown}Given a list of Sale objects, tList, which code fragment… Read More »