1. The following statement creates an InventoryItem array: InventoryItem[] items
ID: 3810646 • Letter: 1
Question
1.
The following statement creates an InventoryItem array:
InventoryItem[] items = new InventoryItem[10];
Is it okay or not okay to execute the following statement;
items[0].setDescription("Skill Saw");
2.
Which of the following statements converts a double variable named tax to a string and stores the value in the String object variable named str?
Question 26 options:
3.
Look at the following declaration statements.
String str = "493.76";
double value;
Write a statement that converts the string referenced by str to a double and stores the result in value.
A) String str = double(tax); B) String str = tax.Double.toString(str); C) String str = double.toString(tax); D) String str = Double.toString(tax);Explanation / Answer
Question1
Answer: It is not okay to execute the statement because we have just declared the array elements but not initialized by new operator. So if we try to execute that statement NullPointerException will occur.
Question 2
Answer:
String str = Double.toString(tax);
Question 3:
Answer:
value = Double.parseDouble(str);
D)String str = Double.toString(tax);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.