Twelve Quick Questions Answer Receive Positive Rate Skipped Rate Negatively 1 Program Refe Q26621714

Twelve VERY quick questions. Answer all to receive positiverate. IF any are skipped, I will rate negatively.

1. [ A program refers to any one ofthese elements with an array-access expressionthat includes the name of the array followed by the index of theparticular element in square brackets([]).] .

T or F? The [] syntax is not a bonafide Java operator.

2. [259:7 An index must be an int valueor a value of a type that can be promoted to int—namely, byte,short, or char, but not long…] Why do you think the long type isnot allowed?

3. T or F? An array containingprimitive-type elements is also considered a primitive type.

4. Define a reference to a 6-by-6 arrayof int named rolls.

5. Write an expression using the arrayinstance variable length that computes to be theindex value of the last element of the 1-dimensional array namedA1.

6. (Continuing 5) Write an expressionusing the array instance variable length that computes to be theindex value of the last element in the last row of the2-dimensional array named A2.

7. When int [] A1 = { 0,1,2,3,0 }; whatis A1.length? ______

8. Define a constantvariable (also called a named constant)named PI initialized with the value 3.14159.

9. Develop a static method namedSum1() that sums the elements of the 1-dimensional intarray named A1 that is passed as the method’s only parameter. NoteYou must use A1’s length instance variable.

10. (Continuing 9) Re-writeSum1() using an enhancedfor-statement.

11. (Continuing 9 and 10) T or F? Theenhanced for-statement is just as powerful as the old-fashionedlength-controlled for-statement.

12. What does printf(“%03d %3d”,12,34);output?

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *