Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1- Considering the functionality of length in an array, which of the following statements is true? length is always a double. length functions as an

1- Considering the functionality of length in an array, which of the following statements is true?

length is always a double.

length functions as an instance variable.

length functions as a method.

size and length can be used interchangeably.

2- Consider the following Java array instantiation code:

int [][] a = new int [x][y];

Where x and y are positive values of type int. What will displayed on screen when a[0].length is printed out?

The value of y

The value of x

0

An error message will be displayed. It is an illegal statement

3- Suppose we want to track the winning lottery numbers (ranging from 1 to 72) and count the number of times each number comes up over the course of a month. In this scenario, we would be wise (most practical with least code / variables / objects) to:

set up 72 int counters with if/else statements.

None of these is correct.

set up an array of int counters with 72 elements.

set up an array of int counters with 72 elements and set up 72 int counters with if/else statements.

4- Consider the following try-catch code section (no finally):

try {

Statement1;

Statement2;

Statement3;

} catch (SomeException newException) {

Statement4;

}

Assume everything is OK with this code and StatementX represent some actual lines of code. Assume that only Statement2 can cause an Exception. If SomeException is caught, which statements will be executed?

Statement1;

Statement2;

Statement4;

Statement2;

Statement3;

Statement4;

Statement1;

Statement4;

Statement1;

Statement2;

Statement3;

5- When using the try-catch-finally construct in Java, only the try block is always guaranteed to be executed (even if not completely). True or false?

True

False

6- Methods of Scanner class objects can be used to process either file or keyboard input. True or false.

True

False

7- Consider the following Java array instantiation code:

Bus [] arr = new Bus [x];

Where x is a positive value of type int and Bus is some existing class (properly written). What is arr, technically?

It is an array object of (Bus class) object references.

It is an array object of int values stored in a Bus class object.

It is an array object of (Bus class) objects.

It is an array type object reference to an array object of (Bus class) object references.

8- Picture a Java 2-dimensional array as a table with columns and rows. Is it possible to create a Java 2-dimensional array ("table") where NOT all rows are of the same length? Yes or no?

Yes

No

9- Consider the following Java array instantiation code:

int [][] arr = n ew int [x][y];

Where x and y are positive values of type int. What is arr, technically?

It is an array type object reference "pointing" to an array object of int type array object references.

It is an object

It is table of int type values

It is a null pointer

10- What would be the most practical approach to traverse an entire 3-dimensional array a and print out all of its elements one by one?

You cannot have a 3-dimensional array in Java

Three nested for loops

The printArray() method from the String class

Two nested for loops and a well-designed if block

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions