Question

Answer question for C# 1 of 10 When items are added or removed, a list resizes...

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

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first...
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first node, and each node contains a pointer to the next node, and the pointer in the last node points back to the first node? A. Circular, singly-linked list. B. Circular, doubly-linked list. C. Singly-linked list. D. Doubly-linked list. E. None of the above.    QUESTION 2 _________ is not an advantage of linked lists when compared to arrays. A. Dynamic memory allocation. B. Efficient...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template <class ItemType> class QueueADT { public:        // Action responsibilities        virtual void resetQueue() = 0;           // Reset the queue to an empty queue.           // Post: Queue is empty.        virtual void add(const ItemType& newItem) = 0;           // Function to add newItem to the queue.           // Pre: The queue exists and is not full.          ...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty queue,...
Please answer the following C question: There is a documented prototype for a function called get_a_line...
Please answer the following C question: There is a documented prototype for a function called get_a_line in the code below. Write a definition for get_a_line—the only function called from that definition should be fgetc. #include <stdio.h> #include <string.h> #define BUFFER_ARRAY_SIZE 10 int get_a_line(char *s, int size, FILE *stream); // Does what fgets does, using repeated calls to fgetc, but // provides a more useful return value than fgets does. // // REQUIRES // size > 1. // s points to...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
QUESTION 6 1.   Why are strings usually primitive (or near-primitive) in modern programming languages?       ...
QUESTION 6 1.   Why are strings usually primitive (or near-primitive) in modern programming languages?        readability        readability and writeability        efficiency        readability, writeability, and efficiency QUESTION 7 1.   There are two main problems with pointers:        dangling pointers & memory leaks        marked sweep and memory leaks        dangling pointers & tombstones        reference counters and marked sweep QUESTION 8 1.   Which of the following implementations of arrays can grow?...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...