Discuss the below:
Q1- In a two-dimensional array, every row must have the same number of columns. true or false
Q2- How do you access the element of array a located at row 2 and column 4?
Q3- An ArrayList can be returned by a method. True or False
Q4-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" }};
Q5- What is the value of the expression cities[2][1]?
Q6-What are the row and column indexes of Chicago in the array cities?
Q7- 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( );
}
Q8- 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 );