Deck 8: Arrays;Introduction to Exception Handling
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/90
Play
Full screen (f)
Deck 8: Arrays;Introduction to Exception Handling
1
Consider the code segment below.Which of the following statements is false
Int[] g;
G = new int[23];
A) The first statement declares an array reference.
B) The second statement creates the array.
C) g is a reference to an array of integers.
D) The value of g[3] is -1.
Int[] g;
G = new int[23];
A) The first statement declares an array reference.
B) The second statement creates the array.
C) g is a reference to an array of integers.
D) The value of g[3] is -1.
D
2
Consider the array:
S[0] = 7
S[1] = 0
S[2] = -12
S[3] = 9
S[4] = 10
S[5] = 3
S[6] = 6
The value of s[s[6] - s[5]] is:
A) 0
B) 3
C) 9
D) 0
S[0] = 7
S[1] = 0
S[2] = -12
S[3] = 9
S[4] = 10
S[5] = 3
S[6] = 6
The value of s[s[6] - s[5]] is:
A) 0
B) 3
C) 9
D) 0
C
3
Arrays are data structures.
A) constant
B) dynamic
C) static
D) None of the above.
A) constant
B) dynamic
C) static
D) None of the above.
C
4
The position number in parentheses is formally called an index.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements about arrays are true
A)An array is a group of variables that all have the same type.
B)Elements are located by index or subscript.
C)The length of an array c is determined by the expression c.Length.
D)The zeroth element of array c is specified by c[0].
A) A, C, D.
B) A, B, D.
C) C, D.
D) A, B, C, D.
A)An array is a group of variables that all have the same type.
B)Elements are located by index or subscript.
C)The length of an array c is determined by the expression c.Length.
D)The zeroth element of array c is specified by c[0].
A) A, C, D.
B) A, B, D.
C) C, D.
D) A, B, C, D.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
6
An array must be declared and allocated in the same statement.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
7
Arrays are allocated with the keyword
A) new
B) array
C) table
D) None of the above.
A) new
B) array
C) table
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
8
Arrays remain the same size once they're created.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
9
The index of an array must be an integer;it cannot include variables or expres
sions.
sions.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
10
In an array of reference types,each element may be a reference to a different type.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following correctly declares and allocates an array of double values
A) double A[15];
B) double() A = new double[15];
C) double[] A = new double[25];
D) All of the above.
A) double A[15];
B) double() A = new double[15];
C) double[] A = new double[25];
D) All of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
12
The number in square brackets after an array name is the of an item.
A) value
B) position
C) size
D) None of the above.
A) value
B) position
C) size
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
13
An array can be supplied values in its declaration by providing an
A) initializer list
B) index
C) array allocation
D) None of the above.
A) initializer list
B) index
C) array allocation
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
14
Arrays may have dimensions.
A) one
B) two
C) more than two
D) All of the above.
A) one
B) two
C) more than two
D) All of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
15
Arrays are data structures that may consist of data items of different types.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
16
The number of elements in an array must be specified in brackets after the array name in the declaration.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
17
Each reference in an array of references is set to null by default when the array is allocated.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following correctly accesses element 13 of array Book
A) Book[0] + 13
B) Book[13]
C) Book[12]
D) None of the above.
A) Book[0] + 13
B) Book[13]
C) Book[12]
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
19
Arrays can be declared to hold only non-class data types.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
20
The first element in every array is the 0th element.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following will not produce a compiler error
A) Changing the value of a constant after it is declared.
B) Changing the value at a given index of an array after it's created.
C) Using a final variable before it is initialized.
D) All of the above will produce compiler errors.
A) Changing the value of a constant after it is declared.
B) Changing the value at a given index of an array after it's created.
C) Using a final variable before it is initialized.
D) All of the above will produce compiler errors.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following statements about creating arrays and initializing their elements is false
A) The new keyword should be used to create an array.
B) When an array is created, the number of elements must be placed in square brackets following the type of element being stored.
C) The elements of an array of integers have a value of null before they are initialized.
D) A for loop is an excellent way to initialize the elements of an array.
A) The new keyword should be used to create an array.
B) When an array is created, the number of elements must be placed in square brackets following the type of element being stored.
C) The elements of an array of integers have a value of null before they are initialized.
D) A for loop is an excellent way to initialize the elements of an array.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
23
Invalid possibilities for array indices include.
A) positive integers
B) negative integers
C) non-consecutive integers
D) zero
A) positive integers
B) negative integers
C) non-consecutive integers
D) zero
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
24
Consider the class below:
Class Test
{
Static void Main()
{
Int[] a = {99,22,11,3,11,55,44,88,2,-3};
Int result = 0;
For (int i = 0;i < a.Length;++i)
{
If (a[i] > 30)
{
Result += a[i];
}
}
Console.WriteLine($"Result is: {result}");
}
}
The output of this C# program will be:
A) Result is: 280
B) Result is: 154
C) Result is: 286
D) Result is: 332
Class Test
{
Static void Main()
{
Int[] a = {99,22,11,3,11,55,44,88,2,-3};
Int result = 0;
For (int i = 0;i < a.Length;++i)
{
If (a[i] > 30)
{
Result += a[i];
}
}
Console.WriteLine($"Result is: {result}");
}
}
The output of this C# program will be:
A) Result is: 280
B) Result is: 154
C) Result is: 286
D) Result is: 332
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
25
The foreach repetition statement requires that you provide an array and a variable for the purpose of:
A) preventing the structure from going past the end of the array
B) storing the value of each element that is traversed
C) acting as a counter to traverse the array
D) None of the above.
A) preventing the structure from going past the end of the array
B) storing the value of each element that is traversed
C) acting as a counter to traverse the array
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
26
Attempting to access an array element out of the bounds of an array causes a(n)________.
A) ArrayOutOfBoundsException.
B) ArrayElementOutOfBoundsException.
C) IndexOutOfRangeException.
D) ArrayException.
A) ArrayOutOfBoundsException.
B) ArrayElementOutOfBoundsException.
C) IndexOutOfRangeException.
D) ArrayException.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
27
Consider the class below:
Class Test
{
Static void Main()
{
Int[] a = new int[10];
For (int i = 0;i < a.Length;++i)
{
A[i] = i + 1 * 2;
}
Int result = 0;
For (int i = 0;i < a.Length;++i)
{
Result += a[i];
}
Console.WriteLine($"Result is: {result}");
}
}
The output of this C# program will be:
A) Result is: 62
B) Result is: 64
C) Result is: 65
D) Result is: 67
Class Test
{
Static void Main()
{
Int[] a = new int[10];
For (int i = 0;i < a.Length;++i)
{
A[i] = i + 1 * 2;
}
Int result = 0;
For (int i = 0;i < a.Length;++i)
{
Result += a[i];
}
Console.WriteLine($"Result is: {result}");
}
}
The output of this C# program will be:
A) Result is: 62
B) Result is: 64
C) Result is: 65
D) Result is: 67
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
28
What do the following statements do
Double[] array;
Array = new double[14];
A) Creates a double array containing 13 elements.
B) Creates a double array containing 14 elements.
C) Creates a double array containing 15 elements.
D) Declares but does not create a double array.
Double[] array;
Array = new double[14];
A) Creates a double array containing 13 elements.
B) Creates a double array containing 14 elements.
C) Creates a double array containing 15 elements.
D) Declares but does not create a double array.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
29
When values are provided upon declaration of an array,the new keyword is not required.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
30
The foreach statement is preferred over the for statement when the indices of the elements in an array will be used in the body of the repetition statement.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
31
Values in an array can be totaled by using the ArrayTotal method.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
32
What can foreach statements iterate through
A)arrays
B)collections
C)databases
D) a and b
A)arrays
B)collections
C)databases
D) a and b
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
33
Constants are declared using keyword
A) static
B) const
C) fixed
D) None of the above.
A) static
B) const
C) fixed
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
34
Which expression adds 1 to the element of array arrayName at index i,assuming the array is of type int
A) ++arrayName[i]
B) arrayName++[i]
C) arrayName[i++]
D) None of the above.
A) ++arrayName[i]
B) arrayName++[i]
C) arrayName[i++]
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
35
C# automatically performs bounds checking to ensure the program doesn't access data outside the bounds of an array.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
36
Constant variables also are called.
A) write-only variables
B) finals
C) named constants
D) All of the above
A) write-only variables
B) finals
C) named constants
D) All of the above
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
37
When a C# program executes,the runtime checks array element indices for validity-all indices must be greater than or equal to 0 and less than the length of the array.Any attempt to access an element outside that range of indices results in a runtime error known as a(n)________.
A) IndexRangeError
B) SubscriptException
C) IndexOutOfRangeException
D) SubscriptRangeError
A) IndexRangeError
B) SubscriptException
C) IndexOutOfRangeException
D) SubscriptRangeError
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
38
What is the proper foreach header format
A)(foreach type_identifer in arrayName)
B)foreach (arrayName)
C)foreach (type_identifer in arrayName)
D)None of the above.
A)(foreach type_identifer in arrayName)
B)foreach (arrayName)
C)foreach (type_identifer in arrayName)
D)None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following initializer lists would correctly set the elements of array n
A) int[] n = {1, 2, 3, 4, 5};
B) array n[int] = {1, 2, 3, 4, 5};
C) int n[5] = {1; 2; 3; 4; 5};
D) int n = new int(1, 2, 3, 4, 5);
A) int[] n = {1, 2, 3, 4, 5};
B) array n[int] = {1, 2, 3, 4, 5};
C) int n[5] = {1; 2; 3; 4; 5};
D) int n = new int(1, 2, 3, 4, 5);
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
40
A constant must be initialized in the same statement where it is declared and cannot be modified.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
41
There are two types of multidimensional arrays:
A) quadrangular and rectangular
B) rectangular and jagged
C) quadrangular and jagged
D) None of the above
A) quadrangular and rectangular
B) rectangular and jagged
C) quadrangular and jagged
D) None of the above
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
42
If you want to pass an array element into a method by reference,what will you need to do
A) It always passes the element as a reference automatically.
C) All of the above.
D) None of the above, passing in by reference of an array element is only possible if the array type is a reference type.
A) It always passes the element as a reference automatically.
C) All of the above.
D) None of the above, passing in by reference of an array element is only possible if the array type is a reference type.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
43
Consider array items,which contains the values 0,2,4,6 and 8.If method changeArray is called with changeArray(items,items[2]),what values are stored in items after the method has finished executing
Public static void ChangeArray(int[] passedArray,int value)
{
PassedArray[value] = 12;
Value = 5;
}
A) 0, 2, 5, 6, 12
B) 0, 2, 12, 6, 8
C) 0, 2, 4, 6, 5
D) 0, 2, 4, 6, 12
Public static void ChangeArray(int[] passedArray,int value)
{
PassedArray[value] = 12;
Value = 5;
}
A) 0, 2, 5, 6, 12
B) 0, 2, 12, 6, 8
C) 0, 2, 4, 6, 5
D) 0, 2, 4, 6, 12
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
44
Which of the following statements is false
A) When the runtime or a method detects a problem, such as an invalid array index or an invalid method argument, it throws an exception-that is, an exception occurs.
B) Exceptions are always thrown by the runtime.
C) To handle an exception, place any code that might throw an exception in a try statement.
D) The try block contains the code that might throw an exception, and the catch block contains the code that handles the exception if one occurs.
A) When the runtime or a method detects a problem, such as an invalid array index or an invalid method argument, it throws an exception-that is, an exception occurs.
B) Exceptions are always thrown by the runtime.
C) To handle an exception, place any code that might throw an exception in a try statement.
D) The try block contains the code that might throw an exception, and the catch block contains the code that handles the exception if one occurs.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following statements is false
A) You can have many catch blocks to handle different types of exceptions that might be thrown in the corresponding try block.
B) The runtime performs array bounds checking.
C) When an exception is thrown, the try block in which it occurs terminates and a corresponding catch block, if there is one, begins executing-if you declared any variables in the try block, they are accessible in the catch block.
D) The catch block declares an exception parameter's type and name. The catch block can handle exceptions of the specified type.
A) You can have many catch blocks to handle different types of exceptions that might be thrown in the corresponding try block.
B) The runtime performs array bounds checking.
C) When an exception is thrown, the try block in which it occurs terminates and a corresponding catch block, if there is one, begins executing-if you declared any variables in the try block, they are accessible in the catch block.
D) The catch block declares an exception parameter's type and name. The catch block can handle exceptions of the specified type.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
46
[C#6] Which of the following statements is false
A)Prior to C# 6,auto-implemented properties required both a get and a set accessor.
B)Client code can use C# 6 getter-only auto-implemented properties only to get each property's value.
C)C#6 getter-only auto-implemented properties are read only.
D)C#6 getter-only auto-implemented properties can be initialized only in their declarations.
A)Prior to C# 6,auto-implemented properties required both a get and a set accessor.
B)Client code can use C# 6 getter-only auto-implemented properties only to get each property's value.
C)C#6 getter-only auto-implemented properties are read only.
D)C#6 getter-only auto-implemented properties can be initialized only in their declarations.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
47
Consider integer array values,which contains 5 elements.Which statements successfully swap the contents of the array at index 3 and index 4
A) values[3] = values[4];
B) values[4] = values[3];
C) int temp = values[3];
D) int temp = values[3];
A) values[3] = values[4];
B) values[4] = values[3];
C) int temp = values[3];
D) int temp = values[3];
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
48
To pass an array argument to a method,specify the name of the array followed by empty brackets.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
49
When an exception is caught,the program can access the exception object's built-in ________ property to get the error message and display it.
A) Error
B) Fault
C) Message
D) Note
A) Error
B) Fault
C) Message
D) Note
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
50
Which function is called when an object is used where a string should be
A)TranslateToString()
B)String()
C)ConvertToString()
D)ToString()
A)TranslateToString()
B)String()
C)ConvertToString()
D)ToString()
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
51
Individual elements of arrays are passed to methods by value.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
52
When accessing an element of an array,operations (calculations)are not allowed inside the brackets of an array.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
53
The keyword _______ overrides an existing method with the same signature.
A)replace
B) override
A)replace
B) override
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
54
[C#6] Initializing an auto-implemented property in its declaration is a C# 6 feature known as auto-property initializers.Which of the following is the general syntax for a read-write auto-implemented property with an initializer
A)Type PropertyName {get,set;} = initializer;
B)Type PropertyName {get | set} = initializer;
C)Type PropertyName {get;set} = initializer;
D)Type PropertyName {get;set;} = initializer;
A)Type PropertyName {get,set;} = initializer;
B)Type PropertyName {get | set} = initializer;
C)Type PropertyName {get;set} = initializer;
D)Type PropertyName {get;set;} = initializer;
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
55
Arrays can hold simple types and reference types.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
56
Which method call does the method header void ModifyArray(double[]
B) ModifyArray(double[] : list)
B) represent
C) ModifyArray(double list[])
D) ModifyArray(list)
B) ModifyArray(double[] : list)
B) represent
C) ModifyArray(double list[])
D) ModifyArray(list)
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
57
Suppose that class Book has been defined.Which of the following creates an array of Book objects
A) Book[] books = new Book[numberElements];
B) Book[] books = new Book()[numberElements];
C) new Book() books[];
D) All of the above.
A) Book[] books = new Book[numberElements];
B) Book[] books = new Book()[numberElements];
C) new Book() books[];
D) All of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
58
Which of the following statements is false
A) An exception indicates a problem that occurs while a program executes.
B) Exception handling helps you create fault-tolerant programs.
C) When an exception is handled, the program continues executing as if no problem was encountered.
D) The compiler does not detect exceptions.
A) An exception indicates a problem that occurs while a program executes.
B) Exception handling helps you create fault-tolerant programs.
C) When an exception is handled, the program continues executing as if no problem was encountered.
D) The compiler does not detect exceptions.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
59
Which foreach header represents iterating through an array of int named numbers
A)foreach (numbers)
B) foreach (number in numbers)
C) foreach (int number in numbers)
D) foreach (int number in int[] numbers)
A)foreach (numbers)
B) foreach (number in numbers)
C) foreach (int number in numbers)
D) foreach (int number in int[] numbers)
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
60
Changes made to an entire array that has been passed to a method will not affect the original values of the array.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
61
The foreach statement can be used only with one-dimensional arrays.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
62
When dealing with multi-dimensional arrays,each "row" must be the same size.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
63
An array with m rows and n columns is not:
A)An m-by-n array.
B)An n-by-m array.
C)A two-dimensional array.
D)An n times m dimensional array.
A) A and C
B) A and D
C) B and D
D) B and C
A)An m-by-n array.
B)An n-by-m array.
C)A two-dimensional array.
D)An n times m dimensional array.
A) A and C
B) A and D
C) B and D
D) B and C
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
64
For the array in the previous question,what is the value returned by items[1, 0].
A) 4
B) 8
C) 12
D) 6
A) 4
B) 8
C) 12
D) 6
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
65
Jagged arrays are maintained as arrays of arrays.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
66
Multi-dimensional arrays require two or more indices to identify particular elements.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
67
Variable-length argument lists allow you to create methods that receive an arbitrary number of arguments.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
68
Tables are often represented with rectangular arrays.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
69
By convention,the first set of brackets of a two-dimensional array identifies an element's column and the second identifies the row.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
70
Which of the following sets of statements creates a multidimensional array with 3 rows,where the first row contains 1 value,the second row contains 4 items and the final row contains 2 items
A)
B)
C)
D)
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
71
In rectangular array items,which expression below retrieve the value at row 3 and column 5
A) items[3. 4]
B) items[3][4]
C) None of the above.
C) items[3, 4]
A) items[3. 4]
B) items[3][4]
C) None of the above.
C) items[3, 4]
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
72
Which statement below initializes array items to contain 3 rows and 2 columns
A) int[,] items = {{2, 4}, {6, 8}, {10, 12}};
B) int[,] items = {{2, 6, 10}, {4, 8, 12}};
C) int[,] items = {2, 4}, {6, 8}, {10, 12};
D) int[,] items = {2, 6, 10}, {4, 8, 12};
A) int[,] items = {{2, 4}, {6, 8}, {10, 12}};
B) int[,] items = {{2, 6, 10}, {4, 8, 12}};
C) int[,] items = {2, 4}, {6, 8}, {10, 12};
D) int[,] items = {2, 6, 10}, {4, 8, 12};
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
73
What is the keyword associated with variable-length argument lists
A) arg
B) params
C) var
D) vla
A) arg
B) params
C) var
D) vla
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
74
Which set of statements totals the items in each row of two-dimensional array items,and displays each total
A) int total = 0;
B) int total = 0;
C) int total = 0;
D) int total = 0;
A) int total = 0;
B) int total = 0;
C) int total = 0;
D) int total = 0;
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
75
Which of the following correctly declares and initializes a two-dimensional rectangular array of integers
A) int[,] sum = new int[3, 4];
B) int[] sum = new int[2, 4];
C) int sum[] = new int[2, 2];
D) None of the above.
A) int[,] sum = new int[3, 4];
B) int[] sum = new int[2, 4];
C) int sum[] = new int[2, 2];
D) None of the above.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
76
is (are)typically used to traverse a two-dimensional array.
A) A do while statement
B) A for statement
C) Two nested for statements
D) Three nested for statements
A) A do while statement
B) A for statement
C) Two nested for statements
D) Three nested for statements
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
77
Rectangular arrays are often used to represent tables of values consisting of information arranged in:
A) rows
B) columns
C) both a and b
D) None of the above
A) rows
B) columns
C) both a and b
D) None of the above
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
78
Which of the following statements creates a multidimensional array with 3 rows,where the first row contains 1 item,the second row contains 4 items and the final row contains 2 items
A) int[][] items = {new int {1, null, null, null},
New int {2, 3, 4, 5},
New int {6, 7, null, null}};
B) int[][] items = {new int {1},
New int {2, 3, 4, 5},
New int {6, 7}};
C) int[][] items = {new int {1},
New int {2, 3, 4, 5},
New int {6, 7},
New int {});
D) int[][] items = {new int {1},
New int {4},
New int {2}};
A) int[][] items = {new int {1, null, null, null},
New int {2, 3, 4, 5},
New int {6, 7, null, null}};
B) int[][] items = {new int {1},
New int {2, 3, 4, 5},
New int {6, 7}};
C) int[][] items = {new int {1},
New int {2, 3, 4, 5},
New int {6, 7},
New int {});
D) int[][] items = {new int {1},
New int {4},
New int {2}};
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
79
One could iterate through multi-dimensional arrays by using nested for loops.
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck
80
What kinds of arrays can variable-length argument lists work with
A) one-dimensional arrays
A) one-dimensional arrays
Unlock Deck
Unlock for access to all 90 flashcards in this deck.
Unlock Deck
k this deck