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

QUESTION 1 If the array myArray is declared as int[ ][ ] myArray = {{2,3},{3,4},

ID: 3872785 • Letter: Q

Question

QUESTION 1

If the array myArray is declared as
   int[ ][ ] myArray = {{2,3},{3,4},{4,5}}
How many rows and columns does it have?

2 rows, 3 columns

3 rows, 2 columns

1 row, 3 columns

3 rows, 1 column

QUESTION 2

If the array myArray is declared as

int[][] myArray = {{2,3},{3,4},{4,5}}

What is the value of myArray[1][1]?

a.2

b.5

c.3

d.4

QUESTION 3

If the array myArray is declared as

int[][] myArray = {{2,3,4,5},{3,4,5,6},{4,5,6,7}}

What is the value of myArray.length?

QUESTION 5

If the array myArray is declared as

int[][] myArray = {{2,3},{3,4,5,6},{4,5,6}}

What is the value of

myArray[1].length

QUESTION 7

Consider the following segment of Java code. What will be the output?

String cat = "Cat";

System.out.println(cat.charAt(1));

changeCat(cat);

System.out.println(cat.charAt(1));

-----------------------------------

public static void changeCat(String dog) {

dog = "Cut";

}

a.Cat

Dog

b.u

a

c.a

u

d.a

a

QUESTION 8

Assertions are used during --?-- and exceptions are used during --?--.

a.running of the program; compilation of the program

b.compilation of the program; running of the program

c.program execution for users; program development

d.program development; program execution for users

QUESTION 9

Suppose in the following program segment, x is supposed to be less than 5. Which of the following is the correct code for <statement A> so that an exception is thrown if that is not the case:

if (! x<5) <statement A>

a.assert (x<5):"x must be < 5";

b,throw new IllegalArgumentException("x must be < 5");

c.throw an IllegalArgumentException("x must be < 5");

d.x = new IllegalArgumentException("x must be < 5");

QUESTION 10

Exceptions in Java are

a.Objects

b.Primitives

c.Never encountered by the programmer.

d.Applications

a.

2 rows, 3 columns

b.

3 rows, 2 columns

c.

1 row, 3 columns

d.

3 rows, 1 column

Explanation / Answer

QUESTION 1:

b. 3 rows, 2 columns

because - in the given array we have 3 sub arrays so it is of 3 rows and in each sub array we have 2 elements so it is of 2 columns therefore given is array consist of 3 rows and 2 columns.

QUESTION 2:

d. 4

for given array position of 1,1 represents 2nd subarray 2nd element so it is of value 4

QUESTION 3:

the value of myArray.length is 3 because the number of subarrays in given arrays are 3 so its length is 3

QUESTION 5:

the value of myArray[1].length is 4 because it refering to the 2nd subarray in the myArray and it consist 4 elements so its lenegth is 4

QUESTION 7:

d. a
   a

because we are calling changeCat method but it is not returning anything so the value in the cat variable does not change so when we print the charecter at 1st position it prints charecter a in both the print statements.

QUESTION 8:

d. program development; program execution for users

Assertions are used during program development to test the program whether it is running correctly or not.

Exceptions are used during program execution for users to avoid the program crashing conditions.

QUESTION 9:

b. throw new IllegalArgumentException("x must be < 5");

QUESTION 10:

a. objects

Exceptions in java are Objects

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