Filters
Question type

Study Flashcards

Which statement correctly passes the array items to method takeArray? Array items contains 10 elements.


A) takeArray(items[]) .
B) takeArray(items) .
C) takeArray(items[9]) .
D) Arrays cannot be passed to methods-each item must be sent to the method separately.

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

When an argument is passed by reference, ________.


A) a copy of the argument's value is passed to the called method
B) changes to the argument do not affect the original variable's value in the caller
C) the called method can access the argument's value in the caller directly and modify that data
D) the original value is removed from memory

E) B) and D)
F) C) and D)

Correct Answer

verifed

verified

In array items, which expression below accesses the value at row 3 and column 4?


A) items[3].[4]
B) items[3[4]]
C) items[3][4]
D) items[3, 4]

E) All of the above
F) C) and D)

Correct Answer

verifed

verified

Which of the following statements creates a multidimensional array with 3 rows, where the first row contains 1 element, the second row contains 4 elements and the final row contains 2 elements?


A) int[][] items = {{1, null, null, null}, {2, 3, 4, 5}, {6, 7, null, null}};
B) int[][] items = {{1}, {2, 3, 4, 5}, {6, 7}};
C) int[][] items = {{1}, {2, 3, 4, 5}, {6, 7}, {}) ;
D) int[][] items = {{1}, {4}, {2}};

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

Which of the following statements is true?


A) The catch block contains the code that might throw an exception.
B) The try block contains the code that handles the exception if one occurs.
C) You can have many catch blocks to handle different types of exceptions.
D) When a try block terminates, any variables declared in the try block are preserved.

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

Constant variables also are called .


A) write-only variables
B) finals
C) named constants
D) All of the above

E) A) and C)
F) A) and D)

Correct Answer

verifed

verified

Attempting to access an array element outside of the bounds of an array, causes a(n) .


A) ArrayOutOfBoundsException.
B) ArrayElementOutOfBoundsException.
C) ArrayIndexOutOfBoundsException.
D) ArrayException.

E) All of the above
F) None of the above

Correct Answer

verifed

verified

What do the following statements do? Double[] array; Array = new double[14];


A) Create a double array containing 13 elements.
B) Create a double array containing 14 elements.
C) Create a double array containing 15 elements.
D) Declare but do not create a double array.

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Class ________ represents a dynamically resizable array-like data structure.


A) Array
B) ArrayList
C) Arrays
D) None of the above.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Which of the following statements is false?


A) When an argument is passed by reference, the called method can access the argument's value in the caller directly but cannot modify it.
B) All arguments in Java are passed by value.
C) To pass an individual array element to a method, use the indexed name of the array.
D) To pass an object reference to a method, simply specify in the method call the name of the variable that refers to the object.

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

Which of the following statements about arrays are true? A. An array is a group of variables containing values that all have the same type. B.Elements are located by index. C. The length of an array c is determined by the expression c.length() ;. D. The zeroth element of array c is specified by c[0].


A) A, C, D.
B) A, B, D.
C) C, D.
D) A, B, C, D.

E) A) and D)
F) A) and B)

Correct Answer

verifed

verified

Which expression adds 1 to the element of array arrayName at index i?


A) ++arrayName[i].
B) arrayName++[i].
C) arrayName[i++].
D) None of the above.

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

An argument type followed by a(n) in a method's parameter list indicates that the method receives a variable number of arguments of that particular type.


A) square brackets ([])
B) ellipsis (...)
C) varargs keyword
D) All of the above are acceptable to indicate a variable number of arguments.

E) A) and D)
F) None of the above

Correct Answer

verifed

verified

Consider the array: S[0] = 7 S[1] = 0 S[2] = -12 S[3] = 9 S[4] = 10 S[5] = 3 S[6] = 6 The value of s[s[6] - s[5]] is:


A) 0 .
B) 3.
C) 9.
D) 0.

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

Invalid possibilities for array indices include .


A) Positive integers.
B) Negative integers.
C) Zero.
D) None of the above.

E) All of the above
F) None of the above

Correct Answer

verifed

verified

Which flag in a format specifier indicates that values with fewer digits than the field width should begin with a leading 0?


A) p.
B) l.
C) w.
D) 0.

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Exception handling helps you create ________ programs.


A) high-performance
B) logic-error-free
C) fault-tolerant
D) compilation-error-free

E) All of the above
F) A) and C)

Correct Answer

verifed

verified

Which of the following will not produce a compiler error?


A) Changing the value of a constant after it is initialized.
B) Changing the value at a given index of an array after it is created.
C) Using a final variable before it is initialized.
D) All of the above will produce compiler errors.

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

Which method sets the background color of a JPanel?


A) setBack.
B) setBackground.
C) setBackgroundColor.
D) setColor.

E) None of the above
F) All of the above

Correct Answer

verifed

verified

A programmer must do the following before using an array:


A) declare then reference the array.
B) create then declare the array.
C) create then reference the array.
D) declare then create the array.

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

Showing 21 - 40 of 48

Related Exams

Show Answer