Deck 9: Advanced Array Concepts

ملء الشاشة (f)
exit full mode
سؤال
When mathematicians use a two-dimensional array, they often call it a ____.

A) grid
B) net
C) matrix
D) mesh
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
In a(n) ____, you continue to compare pairs of items, swapping them if they are out of order, so that the smallest items rise to the top of the list, eventually creating a sorted list.

A) range match
B) bubble sort
C) enhanced for loop
D) float sort
سؤال
Since the Arrays class is part of the java.util package, you can use the java.util.*; import statement to access it.
سؤال
If you do not provide values for the elements in a two-dimensional numeric array, the values default to null.
سؤال
The Arrays class ____ method searches the specified array for the specified key value using the binary search algorithm.

A) binarySearch
B) sort
C) equals
D) search
سؤال
When using the Arrays.binarySearch() method, it is not necessary for the list to be in order because the binarySearch() method will sort the items when called.
سؤال
With a two-dimensional array, the ____ field holds the number of rows in the array.

A) size
B) capacity
C) row
D) length
سؤال
When working with two-dimensional arrays, the length field holds the number of rows in an array and each row has a length field that holds the number of columns in the row.
سؤال
The Arrays class ____ method returns true if the two specified arrays of the same type are equal to one another.

A) compare
B) sort
C) equals
D) fill
سؤال
____ is the process of arranging a series of objects in some logical order.

A) Passing
B) Organizing
C) Sorting
D) Sending
سؤال
You can think of the single dimension of a single dimensional array as the height of the array.
سؤال
How would you create an array named someNumbers that holds three rows and four columns?

A) int[][] someNumbers = new int[4][3]
B) int[][] someNumbers = new int[3][4]
C) int[] someNumbers = new int[3][4]
D) double[][] someNumbers = new int[3][4]
سؤال
To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

A) { }
B) [ ]
C) ( )
D) < >
سؤال
When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.
سؤال
The simplest possible sort involves two values that are out of order.
سؤال
An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array.

A) single-dimensional
B) two-dimensional
C) parallel
D) column
سؤال
The bubble sort is the fastest and most efficient sorting technique.
سؤال
When creating arrays, Java is limited in size due to limitations on the number of variables and subscripts used.
سؤال
When using an insertion sort, each list element is examined one at a time and moved down if the tested element should be inserted before them.
سؤال
Java provides a(n) ____ class, which contains many useful methods for manipulating arrays.

A) Object
B) Arrays
C) Table
D) Sort
سؤال
The Arrays class ____________________ method assigns the specified value to each element of the specified array.
سؤال
Regarding enumerations, the ____ method returns an integer that represents the constant's position in the list of constants; as with arrays, the first position is 0.

A) valueAt
B) positionOf
C) ordinal
D) indexOf
سؤال
The Arrays class ____________________ method sorts the specified array into ascending order.
سؤال
The negative integer returned by the binarySearch() method when the value is not found is the negative equivalent of the array ____.

A) type
B) scope
C) size
D) length
سؤال
int[] myVals = {2, 4, 6, 8} Using the above four-element array, what is the value of myVals[1]?

A) 2
B) 4
C) 6
D) 8
سؤال
int[][] myVals = {{2, 4, 6}, {1, 8, 9},
{1, 3, 5, 7}};
Using the above array, what is the value of myVals[1].length?

A) 1
B) 7
C) 3
D) 6
سؤال
A method that receives a two-dimensional array uses two ____________________ pairs following the data type in the parameter list of the method header.
سؤال
When you place objects in order beginning with the object that has the lowest value, you are sorting in ____________________ order.
سؤال
The ArrayList class ____ method retrieves an item from a specified location in an ArrayList.

A) extract
B) get
C) peek
D) retrieve
سؤال
double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

A) insertion
B) sort
C) ragged
D) boolean
سؤال
An ArrayList's ____ is the number of items it can hold without having to increase its size.

A) length
B) buffer
C) capacity
D) size
سؤال
The ArrayList class ____ method returns the current ArrayList size.

A) size
B) capacity
C) length
D) rows
سؤال
Programmers often refer to a ____ search as a "divide and conquer" procedure.

A) bubble
B) binary
C) division
D) split
سؤال
When you start with the object that has the largest value, you are sorting in ____________________ order.
سؤال
In Java, you create an enumerated data type in a statement that uses the keyword ____.

A) new
B) sequence
C) collection
D) enum
سؤال
int[][] myVals = {{2, 4, 6}, {1, 3, 5, 7}};
Using the above array, what is the value of myVals.length?

A) 1
B) 2
C) 4
D) 5
سؤال
The ArrayList class ____ method removes an item from an ArrayList at a specified location.

A) delete
B) get
C) erase
D) remove
سؤال
You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

A) ArrayList
B) Array
C) ResizableArray
D) array
سؤال
Regarding enumerations, the ____ method returns the name of the calling constant object.

A) toString
B) constName
C) ordinal
D) nameOf
سؤال
Regarding enumerations, the ____ method returns an array of the enumerated constants.

A) valueOf
B) values
C) ordinal
D) toArray
سؤال
What are some of the advantages of declaring an ArrayList with a specified type?
سؤال
What are some of the advantages of creating an enumeration type?
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Use them with the class name without instantiating an object
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A popularly known sorting method
سؤال
Describe how to visualize the following array. How would you identify the location of the 99 that is stored in the array?
int[][] someNumbers = {{8, 9, 10, 11},
{1, 3, 12, 15},
{5, 9, 44, 99} };
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A two-dimensional array that has rows of different lengths
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Two or more columns of values
سؤال
How can you use the length field with a two-dimensional array?
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Adds an item to the end of an ArrayList
سؤال
What are some of the advantages of the ArrayList class over the Arrays class?
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Alters an item at a specified ArrayList location
سؤال
How can you sort arrays of objects?
سؤال
How can you pass a two-dimensional array to a method?
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A programmer-created data type with a fixed set of values
سؤال
Write the statement that assigns the integer value 20 to the first column of the first row of an array named myVals.
سؤال
Write the code for bubble sorting a someNums array of integers.
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Arrays with more than one dimension; allowed in Java
سؤال
What are the limitations of the ArrayList class?
سؤال
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A package containing the Arrays class
سؤال
What is sorting and how are objects organized as a result of being sorted?
سؤال
Write the statement to declare a three-by-four array of integers with the elements initialized to zero. Name the array myArray.
سؤال
int[][] myVals = {{10, 15, 20, 25},
{30, 35, 40, 45, 50, 55, 60},
{65, 70, 75, 80, 85, 90}};
Using the above array, what is the value of myVals.length? What is the value of myVals[1].length? What is the value of myVals[2].length? Explain how you determined these values.
سؤال
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,
سؤال
int[][] studentScores = {{70, 82, 90, 68},
{95, 75, 67, 89},
{98, 79, 57, 81}};
Using the above two-dimensional array, what is the value of studentScores[0][0]? What is the value of studentScores[2][3]? What is the value of studentScores[1][2]? Describe how arrays reference values with subscripts.
سؤال
Dummy values are a common programming technique used with arrays. Explain the importance of dummy values and how they can be used to ensure that the subscript does not exceed the allowable limit.
سؤال
Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList.
سؤال
enum Color {RED, GREEN, BLUE}
public class EnumOrdinal
{
public static void main(String[] args)
{
____
____
____
}
}
The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the shaded lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.
سؤال
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,
سؤال
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.
سؤال
import java.util.*;
public class myArray
{
public static void main(String[] args)
{
int myVals = new int[4];
____
display("My values are: ", myVals);
}
public static void display(String message, int array[])
{
int arraySize = array.length;
System.out.print(message);
for(int x = 0; x < arraySize; ++x)
System.out.print(array[x] + " ");
}
}
Using the above code, complete the shaded section with a fill method() to fill each array element with a value of 2. What will be displayed after the display() method is executed?
سؤال
Using the ArrayList add() method, write the statement to insert "July" in the first position of the months ArrayList. Describe what would happen if the position number is invalid for the ArrayList.
سؤال
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?
سؤال
import java.util.*;
public class sortArray
{
public static void main(String[] args)
{
double[] lengths = {120.0, 0.5, 0.0, 999.0, 77.3};
Arrays.sort(lengths);
System.out.println(Arrays.toString(lengths));
}
}
Using the above code, what will be the output of the println statement when the code is executed?
سؤال
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.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/74
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Advanced Array Concepts
1
When mathematicians use a two-dimensional array, they often call it a ____.

A) grid
B) net
C) matrix
D) mesh
C
2
In a(n) ____, you continue to compare pairs of items, swapping them if they are out of order, so that the smallest items rise to the top of the list, eventually creating a sorted list.

A) range match
B) bubble sort
C) enhanced for loop
D) float sort
B
3
Since the Arrays class is part of the java.util package, you can use the java.util.*; import statement to access it.
True
4
If you do not provide values for the elements in a two-dimensional numeric array, the values default to null.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
5
The Arrays class ____ method searches the specified array for the specified key value using the binary search algorithm.

A) binarySearch
B) sort
C) equals
D) search
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
6
When using the Arrays.binarySearch() method, it is not necessary for the list to be in order because the binarySearch() method will sort the items when called.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
7
With a two-dimensional array, the ____ field holds the number of rows in the array.

A) size
B) capacity
C) row
D) length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
8
When working with two-dimensional arrays, the length field holds the number of rows in an array and each row has a length field that holds the number of columns in the row.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
9
The Arrays class ____ method returns true if the two specified arrays of the same type are equal to one another.

A) compare
B) sort
C) equals
D) fill
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
10
____ is the process of arranging a series of objects in some logical order.

A) Passing
B) Organizing
C) Sorting
D) Sending
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
11
You can think of the single dimension of a single dimensional array as the height of the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
12
How would you create an array named someNumbers that holds three rows and four columns?

A) int[][] someNumbers = new int[4][3]
B) int[][] someNumbers = new int[3][4]
C) int[] someNumbers = new int[3][4]
D) double[][] someNumbers = new int[3][4]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
13
To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

A) { }
B) [ ]
C) ( )
D) < >
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
14
When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
15
The simplest possible sort involves two values that are out of order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
16
An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array.

A) single-dimensional
B) two-dimensional
C) parallel
D) column
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
17
The bubble sort is the fastest and most efficient sorting technique.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
18
When creating arrays, Java is limited in size due to limitations on the number of variables and subscripts used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
19
When using an insertion sort, each list element is examined one at a time and moved down if the tested element should be inserted before them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
20
Java provides a(n) ____ class, which contains many useful methods for manipulating arrays.

A) Object
B) Arrays
C) Table
D) Sort
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
21
The Arrays class ____________________ method assigns the specified value to each element of the specified array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
22
Regarding enumerations, the ____ method returns an integer that represents the constant's position in the list of constants; as with arrays, the first position is 0.

A) valueAt
B) positionOf
C) ordinal
D) indexOf
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
23
The Arrays class ____________________ method sorts the specified array into ascending order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
24
The negative integer returned by the binarySearch() method when the value is not found is the negative equivalent of the array ____.

A) type
B) scope
C) size
D) length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
25
int[] myVals = {2, 4, 6, 8} Using the above four-element array, what is the value of myVals[1]?

A) 2
B) 4
C) 6
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
26
int[][] myVals = {{2, 4, 6}, {1, 8, 9},
{1, 3, 5, 7}};
Using the above array, what is the value of myVals[1].length?

A) 1
B) 7
C) 3
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
27
A method that receives a two-dimensional array uses two ____________________ pairs following the data type in the parameter list of the method header.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
28
When you place objects in order beginning with the object that has the lowest value, you are sorting in ____________________ order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
29
The ArrayList class ____ method retrieves an item from a specified location in an ArrayList.

A) extract
B) get
C) peek
D) retrieve
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
30
double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

A) insertion
B) sort
C) ragged
D) boolean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
31
An ArrayList's ____ is the number of items it can hold without having to increase its size.

A) length
B) buffer
C) capacity
D) size
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
32
The ArrayList class ____ method returns the current ArrayList size.

A) size
B) capacity
C) length
D) rows
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
33
Programmers often refer to a ____ search as a "divide and conquer" procedure.

A) bubble
B) binary
C) division
D) split
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
34
When you start with the object that has the largest value, you are sorting in ____________________ order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
35
In Java, you create an enumerated data type in a statement that uses the keyword ____.

A) new
B) sequence
C) collection
D) enum
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
36
int[][] myVals = {{2, 4, 6}, {1, 3, 5, 7}};
Using the above array, what is the value of myVals.length?

A) 1
B) 2
C) 4
D) 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
37
The ArrayList class ____ method removes an item from an ArrayList at a specified location.

A) delete
B) get
C) erase
D) remove
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
38
You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

A) ArrayList
B) Array
C) ResizableArray
D) array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
39
Regarding enumerations, the ____ method returns the name of the calling constant object.

A) toString
B) constName
C) ordinal
D) nameOf
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
40
Regarding enumerations, the ____ method returns an array of the enumerated constants.

A) valueOf
B) values
C) ordinal
D) toArray
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
41
What are some of the advantages of declaring an ArrayList with a specified type?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
42
What are some of the advantages of creating an enumeration type?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
43
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Use them with the class name without instantiating an object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
44
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A popularly known sorting method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
45
Describe how to visualize the following array. How would you identify the location of the 99 that is stored in the array?
int[][] someNumbers = {{8, 9, 10, 11},
{1, 3, 12, 15},
{5, 9, 44, 99} };
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
46
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A two-dimensional array that has rows of different lengths
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
47
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Two or more columns of values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
48
How can you use the length field with a two-dimensional array?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Adds an item to the end of an ArrayList
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
50
What are some of the advantages of the ArrayList class over the Arrays class?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Alters an item at a specified ArrayList location
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
52
How can you sort arrays of objects?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
53
How can you pass a two-dimensional array to a method?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
54
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A programmer-created data type with a fixed set of values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
55
Write the statement that assigns the integer value 20 to the first column of the first row of an array named myVals.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
56
Write the code for bubble sorting a someNums array of integers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
57
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
Arrays with more than one dimension; allowed in Java
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
58
What are the limitations of the ArrayList class?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
59
Match each term with the correct statement below.
a.ragged array
f.Enumerated data type
b.bubble sort
g.set() method
c.static methods
h.multidimensional array
d.two-dimensional array
i.java.util
e.add() method
A package containing the Arrays class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
60
What is sorting and how are objects organized as a result of being sorted?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
61
Write the statement to declare a three-by-four array of integers with the elements initialized to zero. Name the array myArray.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
62
int[][] myVals = {{10, 15, 20, 25},
{30, 35, 40, 45, 50, 55, 60},
{65, 70, 75, 80, 85, 90}};
Using the above array, what is the value of myVals.length? What is the value of myVals[1].length? What is the value of myVals[2].length? Explain how you determined these values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
63
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,
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
64
int[][] studentScores = {{70, 82, 90, 68},
{95, 75, 67, 89},
{98, 79, 57, 81}};
Using the above two-dimensional array, what is the value of studentScores[0][0]? What is the value of studentScores[2][3]? What is the value of studentScores[1][2]? Describe how arrays reference values with subscripts.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
65
Dummy values are a common programming technique used with arrays. Explain the importance of dummy values and how they can be used to ensure that the subscript does not exceed the allowable limit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
66
Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
67
enum Color {RED, GREEN, BLUE}
public class EnumOrdinal
{
public static void main(String[] args)
{
____
____
____
}
}
The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the shaded lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
68
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,
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
69
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
70
import java.util.*;
public class myArray
{
public static void main(String[] args)
{
int myVals = new int[4];
____
display("My values are: ", myVals);
}
public static void display(String message, int array[])
{
int arraySize = array.length;
System.out.print(message);
for(int x = 0; x < arraySize; ++x)
System.out.print(array[x] + " ");
}
}
Using the above code, complete the shaded section with a fill method() to fill each array element with a value of 2. What will be displayed after the display() method is executed?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
71
Using the ArrayList add() method, write the statement to insert "July" in the first position of the months ArrayList. Describe what would happen if the position number is invalid for the ArrayList.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
72
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
73
import java.util.*;
public class sortArray
{
public static void main(String[] args)
{
double[] lengths = {120.0, 0.5, 0.0, 999.0, 77.3};
Arrays.sort(lengths);
System.out.println(Arrays.toString(lengths));
}
}
Using the above code, what will be the output of the println statement when the code is executed?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
74
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 74 في هذه المجموعة.