Explore BrainMass

Explore BrainMass

    Java Array Coding

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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 )
    System.out.println( " count is " + count );

    © BrainMass Inc. brainmass.com October 10, 2019, 6:51 am ad1c9bdddf

    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.


    (--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 ...

    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.