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

5 Java Basic Multiple Questions 1)Which of the following is false about type Arr

ID: 3872848 • Letter: 5

Question

5 Java Basic Multiple Questions

1)Which of the following is false about type ArrayList:

The add operation always increases the size by 1.

Only objects can be stored in an ArrayList.

The addAll method may increase the capacity by more than one.

The capacity of an ArrayList can be changed using the set method.

none of the above is false

2) Which of the following is not true about arrays?

Arrays are reference types.

Array indexing is bounded by the language.

Arrays sometimes can be created without using new.

The entire contents of an array can be copied via the assignment operator (=).

The capacity of an array can always be determined.

3) Which of the following statements is true?

Any method that compiles without error is guaranteed to be logically correct.

Java provides a mechanism to distinguish between accessor and mutator methods.

Each class can provide a main to perform testing.

The keyword this is available in all methods, including static methods.

Every class must implement toString and equals.

4)What happens if a line of code in a different class attempts to access a private member directly rather than through its accessor methods?

compile time error

compile time warning, but program compiles

the program compiles but the results are undefined

the program is certain to crash

some of the above, but the result varies from system to system

5) Which of (a) to (c) is false about a static class member?

it must be a method

one member is allocated for each declared class object

the static class member is guaranteed to be private to the class

two of the above are false

all of (a), (b), and (c) are false

a.

The add operation always increases the size by 1.

b,

Only objects can be stored in an ArrayList.

c,

The addAll method may increase the capacity by more than one.

d.

The capacity of an ArrayList can be changed using the set method.

e.

none of the above is false

Explanation / Answer

1 . d The capacity of an ArrayList can be changed using the set method.

set method replaces specified element at index with element passed as parameter.

2. c. Arrays sometimes can be created without using new.

3. c. Each class can provide a main to perform testing.

4. a)compile time error

5) e)all of (a), (b), and (c) are false

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