Filters
Question type

Study Flashcards

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

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

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.

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

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)

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

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.

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

Passing a reference with keyword ref gives the called method control over the passed reference itself.

A) True
B) False

Correct Answer

verifed

verified

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

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

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) ;

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

Which method call does the method header void ModifyArray(double[] b) represent ? Assume that the array being passed in is already defined and is called list.


A) ModifyArray(double[] list)
B) ModifyArray(double[] : list)
C) ModifyArray(double list[])
D) ModifyArray(list)

E) All of the above
F) A) and D)

Correct Answer

verifed

verified

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

E) A) and D)
F) All of the above

Correct Answer

verifed

verified

Each reference in an array of references is set to null by default when the array is allocated.

A) True
B) False

Correct Answer

verifed

verified

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.

E) None of the above
F) B) and D)

Correct Answer

verifed

verified

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.
B) Use the keyword ref and/or out.
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.

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

When accessing an element of an array,operations (calculations)are not allowed inside the brackets of an array.

A) True
B) False

Correct Answer

verifed

verified

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.

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

In an array of reference types,each element may be a reference to a different type.

A) True
B) False

Correct Answer

verifed

verified

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

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

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];
values[4] = values[3];
B)
values[4] = values[3];
values[3] = values[4];
C)
int temp = values[3];
values[3] = values[4];
values[4] = temp;
D)
int temp = values[3];
values[3] = values[4];
values[4] = values[3];

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

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.

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

The first element in every array is the 0th element.

A) True
B) False

Correct Answer

verifed

verified

When an app is executed from the Command Prompt,the execution environment passes the command-line arguments to the Main method as a string.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 90

Related Exams

Show Answer