Purchase Solution

Java Array Coding

Not what you're looking for?

Ask Custom Question

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

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

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

11-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" }};

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

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

21- 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( );
}

23- 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 );

Purchase this Solution

Solution Summary

A two-dimensional array for every row which must have the same number of columns. How to access the elements of array to locate at row 2 and column 4 is discussed.

Solution Preview

Dear student,

Please find below the answers.
Let me know if you have any doubt/confusion about anything.

Please do not forget to give a "5" and a positive comment once you are done.

Thanks.

(--Please note that my work should only be used as a guidance and not be copied into your assignments.
The answers available here are meant for assistance and the understanding of challenging academic topics.
Use the solution alongside your own work and watch your knowledge and grades ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.