Identify two benefits of using ArrayList over array in software development.
Correct Answer: A,D
ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays are of a fixed length. After arrays are created, they cannot grow or shrink, which means that you must know in advance how many elements an array will hold. But, sometimes, you may not know until run time precisely how large of an array you need. To handle this situation, the collections framework defines ArrayList. In essence, an ArrayList is a variable-length array of object references. That is, an ArrayList can dynamically increase or decrease in size. Array lists are created with an initial size. When this size is exceeded, the collection is automatically enlarged. When objects are removed, the array may be shrunk.
Question 57
Given the code fragment: Which code fragment, when inserted at line 3, enables the code to print 10:20?
Correct Answer: C
Question 58
Given the following classes: Which two options fail to compile when placed at line n1 of the main method? (Choose two.)
Correct Answer: A,C
Question 59
Given the code fragment: What is the result?
Correct Answer: D
Question 60
Given: And given the code fragment: What is the result?