Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following statements are correct? When you create an array using ne

ID: 3829698 • Letter: W

Question

Which of the following statements are correct?

When you create an array using new int[10], an array object is created with ten integers of value 0.

When you create an array using new int[10], an array object is created with no values in the array.

When you create an ArrayList using new ArrayList(), an ArrayList object is created with no elements in the ArrayList object.

When you create an array using int[] x = new int[10], x.length() is 10.

When you create an array using ArrayList x = new ArrayList(10), x.size() is 10.

When you create an array using new int[10], an array object is created with ten integers of value 0.

When you create an array using new int[10], an array object is created with no values in the array.

When you create an ArrayList using new ArrayList(), an ArrayList object is created with no elements in the ArrayList object.

When you create an array using int[] x = new int[10], x.length() is 10.

When you create an array using ArrayList x = new ArrayList(10), x.size() is 10.

Explanation / Answer

1. True : new operator initializes a new object.In this case an integer array of size 10. Default values in an array are 0 for int

2. False : new operator icreates a new object with 10 values in it all being zeros.

3. True : ArrayList object is created when we create a new one using new operator.

4. False. : Actually x.length is 10, but not x.length() is 10.. There is not method .length() on array object.

5. False : Here constructor specifies the default capacity, not the size of the list.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote