Exam 9: Advanced Array Concepts
Exam 1: Creating Java Programs61 Questions
Exam 2: Using Data67 Questions
Exam 3: Using Methods Classes and Objects66 Questions
Exam 4: More Object Concepts66 Questions
Exam 5: Making Decisions66 Questions
Exam 6: Looping66 Questions
Exam 7: Characters Strings and the Stringbuilder68 Questions
Exam 8: Arrays66 Questions
Exam 9: Advanced Array Concepts66 Questions
Exam 10: Introduction to Inheritance66 Questions
Exam 11: Advanced Inheritance Concepts66 Questions
Exam 12: Exception Handling66 Questions
Exam 13: File Input and Output66 Questions
Exam 14: Introduction to Swing Components66 Questions
Exam 15: Advanced Gui Topics66 Questions
Exam 16: Graphics66 Questions
Select questions type
A method that receives a two-dimensional array uses two ____________________ pairs following the data type in the parameter list of the method header.
(Short Answer)
4.9/5
(43)
You can think of the single dimension of a single dimensional array as the height of the array.
(True/False)
5.0/5
(44)
You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.
(Multiple Choice)
4.7/5
(35)
import javax.swing.*;
class FindPoints
{
public static void main(String[] args)
{
int[][] points =
{{10, 20, 30},
{20, 40, 60},
{40, 60, 80}};
String prompt;
int class;
int level;
prompt = JOptionPane.showInputDialog(null, "Class: ");
class = Integer.parseInt(prompt);
prompt = JOptionPane.showInputDialog(null, "Level: ");
level = Integer.parseInt(prompt);
JOption.showMessageDialog(null, "Your points: " + points[class][level]);
}
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. If a user inputs a Class of 1 and a Level of 2, what point value will be displayed when the program executes? Explain how you arrived at your answer.
(Essay)
4.7/5
(34)
int[][] myVals = {{2, 4, 6}, {1, 3, 5, 7}};
Using the above array, what is the value of myVals.length ?
(Multiple Choice)
4.9/5
(40)
The ArrayList class ____ method retrieves an item from a specified location in an ArrayList .
(Multiple Choice)
4.9/5
(37)
import java.util.*;
import javax.swing.*;
public class binary_search
{
public static void main(String[] args)
{
int myNums[]={2, 44, 5, 66, 78, 90, 23, 66};
int point, find = 78;
point = Arrays.binarySearch(myNums, find);
System.out.println("Element found at index " + point);
}
}
Using the above code, what output will be displayed when the program is executed? Describe how the binarySearch() method functions.
(Essay)
4.9/5
(35)
The Arrays class ____________________ method assigns the specified value to each element of the specified array.
(Short Answer)
4.8/5
(33)
When creating arrays, Java is limited in size due to limitations on the number of variables and subscripts used.
(True/False)
4.8/5
(28)
When you place objects in order beginning with the object that has the lowest value, you are sorting in ____________________ order.
(Short Answer)
4.9/5
(37)
public class EnumExample
{
enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY };
Day day;
public EnumExample(Day day)
{
this.day = day;
}
public void giveFeedback()
{
switch (day)
{
case MONDAY:
System.out.println("Mondays are bad.");
break;
case FRIDAY:
System.out.println("Fridays are better.");
break;
case SATURDAY: case SUNDAY:
System.out.println("Weekends are best.");
break;
default:
System.out.println("Midweek days are so-so.");
break;
}
}
public static void main(String[] args)
{
EnumExample firstDay = new EnumExample(Day.MONDAY);
firstDay.giveFeedback();
EnumExample thirdDay = new EnumExample(Day.WEDNESDAY);
thirdDay.giveFeedback();
EnumExample fifthDay = new EnumExample(Day.FRIDAY);
fifthDay.giveFeedback();
EnumExample sixthDay = new EnumExample(Day.SATURDAY);
sixthDay.giveFeedback();
EnumExample seventhDay = new EnumExample(Day.SUNDAY);
seventhDay.giveFeedback();
}
}
Using the above enumeration and code, what will be the output when the program is executed?
(Essay)
4.7/5
(30)
import javax.swing.*;
class FindPoints
{
public static void main(String[] args)
{
int[][] points =
{{10, 20, 30},
{20, 40, 60},
{40, 60, 80}};
String prompt;
int class;
int level;
prompt = JOptionPane.showInputDialog(null, "Class: ");
class = Integer.parseInt(prompt);
prompt = JOptionPane.showInputDialog(null, "Level: ");
level = Integer.parseInt(prompt);
JOption.showMessageDialog(null, "Your points: " + ---complete code here-----);
}
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. Complete the JOption command so that the code will determine a point value based on the points array.
(Essay)
4.8/5
(44)
When mathematicians use a two-dimensional array, they often call it a ____.
(Multiple Choice)
4.7/5
(36)
If you do not provide values for the elements in a two-dimensional numeric array, the values default to null .
(True/False)
4.9/5
(38)
The Arrays class ____________________ method sorts the specified array into ascending order.
(Short Answer)
4.9/5
(36)
In a(n) ____, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list.
(Multiple Choice)
4.8/5
(40)
int[][] myVals = new int[3][]
myVals[0] = new int[3];
myVals[1] = new int[10];
myVals[2] = new int[5];
The above code depicts a ragged array. What does this mean? Describe the rows and columns that make up this array.
(Essay)
4.8/5
(38)
int[][] myVals = {{2, 4, 6, 8}, {20, 40, 60, 80} };
Using the above two-dimensional array, what is the value of myVals[1][2] ?
(Multiple Choice)
4.9/5
(40)
What is sorting and how are objects organized as a result of being sorted?
(Essay)
4.9/5
(42)
With a two-dimensional array, the ____ field holds the number of rows in the array.
(Multiple Choice)
4.9/5
(40)
Showing 21 - 40 of 66
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)