Question: 5 Java Basic Multiple Questions 1)Which of the following is false about type ArrayList: a. The add operation always increases the size by 1. b,
5 Java Basic Multiple Questions
1)Which of the following is false about type ArrayList:
| 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 |
2) Which of the following is not true about arrays?
| a. | Arrays are reference types. | |
| b. | Array indexing is bounded by the language. | |
| c. | Arrays sometimes can be created without using new. | |
| d. | The entire contents of an array can be copied via the assignment operator (=). | |
| e. | The capacity of an array can always be determined. |
3) Which of the following statements is true?
| a. | Any method that compiles without error is guaranteed to be logically correct. | |
| b. | Java provides a mechanism to distinguish between accessor and mutator methods. | |
| c. | Each class can provide a main to perform testing. | |
| d. | The keyword this is available in all methods, including static methods. | |
| e. | 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?
| a. | compile time error | |
| b. | compile time warning, but program compiles | |
| c. | the program compiles but the results are undefined | |
| d. | the program is certain to crash | |
| e. | 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?
| a. | it must be a method | |
| b. | one member is allocated for each declared class object | |
| c. | the static class member is guaranteed to be private to the class | |
| d. | two of the above are false | |
| e. | all of (a), (b), and (c) are false |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
