Question: 16. Consider the following method. public int someCode(int a, int b, int c) { if ((a < b) && (b < c)) return a; if
16. Consider the following method.
public int someCode(int a, int b, int c) { if ((a < b) && (b < c)) return a; if ((a >= b) && (b >= c)) return b; if ((a == b) || (a == c) || (b == c)) return c; }
Which of the following best describes why this method does not compile?
Question 16 options:
| Methods cannot have multiple return statements. | |
| The reserved word return cannot be used in the body of an if statement. | |
| The third if statement is not reachable. | |
| The if statments must have else parts when they contain return statements. | |
| It is possible to reach the end of the method without returning a value. |
17. Which of the following is a reason to use an ArrayList instead of an array?
Question 17 options:
| An ArrayList always uses less memory than an array does. | |||||||||||
| An ArrayList resizes itself as necessary when items are added, but an array does not. | |||||||||||
| An ArrayList allows faster access to its kth item than an array does. | |||||||||||
| An ArrayList provides access t the number of items it stores, but an array does not. | |||||||||||
| 20. Integers can be represented using different bases. Base 10 (decimal), and base 16(hexadecimal) are indicated with the subscripts dec and hex, respectively. For example the decimal number 23 can also be represented in base 16 as shown below. 23dec = 17hex Which of the following is equal to 100hex - 10hex? Question 20 options:
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
