What is the value of the expression


1 In a two-dimensional array, every row must have the same number of columns. true or false

2 How do you access the element of array a located at row 2 and column 4?

3 An ArrayList can be returned by a method. True or False

4 Is is possible to declare and instantiate an ArrayList of a user-defined class type. True or False

For question 14 to 24, consider the following two-dimensional array declaration and initialization:
String [ ] [ ] cities = { {"New York", "LA", "San Francisco", "Chicago" },
{"Munich", "Stuttgart", " Berlin", "Bonn" },
{ "Paris", "Ajaccio", "Lyon" },
{ " Montreal", "Ottawa", "Vancouver" }};

5 What is the value of the expression cities[2][1]?

6 What are the row and column indexes of Chicago in the array cities?

7  What is the output of this code sequence?
for ( int i = 0; i < cities.length; i++ )
{
for ( int j = 0; j < cities [i].length; j++ )
System.out.print( cities[i][j] + "t" );
System.out.println( );
}

8  What is the output of this code sequence?
int count = 0;for ( int i = 0; i < cities.length; i++ )
{
for ( int j= 0; j< cities.length; i++ )
{
If ( cities [i][j].length( ) ==7 )
count++;
}
}
System.out.println( " count is " + count );

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: What is the value of the expression
Reference No:- TGS01249218

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)