Answer question for C#
1 of 10
When items are added or removed, a list resizes itself.
True | |
False |
Question
2 of 10
What happens when you assign one list to another using the assignment operator?
An error message generates. | |
Elements copy to new memory locations. | |
Both lists become value-type data elements. | |
Both lists reference the same memory locations. |
Question
3 of 10
Which of the following is a valid example of calling a method and sending it an array argument?
DisplayArrayContents(iList aList; | |
DisplayArrayContents(aList); | |
DisplayArrayContents(aList[10]); | |
DisplayArrayContents(int [ 10] aList); |
Question
4 of 10
Given the following code, how would you access the third value in the array?
List<int> list = new List<int> { 5, 10, 15, 20 };
Console.WriteLine(list[2]);
Console.ReadLine();
list[3] | |
list[2]; | |
A compile-time error occurs. | |
A run-time error occurs. |
Question
5 of 10
Just like arrays, lists contain a Length property.
True | |
False |
Question
6 of 10
A ___ works similarly to an array; however, when you add or remove items it resizes itself.
list | |
queue | |
stack | |
dictionary |
Question
7 of 10
You declare a list with code like below:
List<int> items = new List<int>();
You try to access the value using the code below, without adding items first:
int listValue = items[10];
What will happen?
A compilation error generates. | |
A run-time error generates. | |
The variable arrayValue sets to the 11th element in the array. | |
The variable arrayValue sets to the 10th element in the array. |
Question
8 of 10
The key and value in a dictionary must be of the same type.
True | |
False |
Question
9 of 10
A ____ is a data structure that uses a first-in-first-out order of accessing items.
list | |
queue | |
stack | |
dictionary |
Question
10 of 10
Given the code below, what type is the key of this dictionary?
Dictionary<int, string> students = new Dictionary<int, string>();
string | |
int | |
Dictionary | |
None of the above |
Answer 1:true
list grows dynamically
Answer 2: Both lists reference the same memory locations.
both will point same reference as both are pointing to same
object
Answer 3:DisplayArrayContents(aList);
when we are passing array we will just send the name of the
array
Wrong Answers:
we dont write size while passing as argument
we dont use [] while passing as argument
Answer 4:list[2];
indexes starts from 0 so 3rd element index will be 2
Wrong Answer:
index 3 means it will give 4th value
Console.ReadLine() to read input from the user
As per policy we can answer 1 question per post. Please post the remianing questions as separate post.Thanks
Get Answers For Free
Most questions answered within 1 hours.