Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# 1.What is an advantage of using a List over an array? List automatically resizes itself if more space is required for additional objects. List

C#

1.What is an advantage of using a List over an array?

List automatically resizes itself if more space is required for additional objects.

List stores its data contiguously, which is faster than an array.

There is no advantage.

It is easier to iterate over all of the elements of a List than it is to iterate through an array's elements.

2. What does this code print?

Dictionary minivans = new Dictionary()
{
 { "Ford", "Aerostar" },
 { "Honda", "Odyssey"},
 { "Toyota", "Sienna"}
};
if(minivans.TryGetValue("Nissan", out string model))
{
 Console.WriteLine($"Nissan Model: {model}");
}
 

Nissan Model: Sentra

Nissan Model:

KeyNotFoundException

nothing

Nissan Model: {model}

3. What are the primary benefits of object-oriented programming? (Choose all that apply)

Polymorphism

Virtual functions

Encapsulation

Inheritance

Constructors

Abstraction

4. What class would best be used to read a file in a "plain text" format?

StreamReader

BinaryReader

XmlReader

StringBuilder

5. What types of functions can use the base initializer?

all constructors

default constructors -and- destructors

destructors

properties

6. The less you _____ the fewer ______ you'll write.

think, lines of code

debug, programs

type, bugs

care, tests

7. When casting from a derived type variable to a base type variable, that is what kind of casting?

implicit

explicit

upcasting

downcasting

8. How would you add each kind of monster to a List?

public static class MonsterFactory
{
 public static IMonster CreateFrankenstein()
 {
 return new Frankenstein("Franken Berry");
 }
 
 public static IMonster CreateVampire()
 {
 return new Vampire("Count Chocula");
 }
}

List monsters = new List();

monsters.Add(CreateFrankenstein());

monsters.Add(CreateVampire());

List monsters = new List();

monsters.Add(MonsterFactory.CreateFrankenstein());

monsters.Add(MonsterFactory.CreateVampire());

List monsters = new List();

monsters.Add("Franken Berry");

monsters.Add("Count Chocula");

List monsters = new List();

monsters.Add(CreateFrankenstein());

monsters.Add(CreateVampire());

List monsters = new List(); monsters.Add(MonsterFactory.CreateFrankenstein());

monsters.Add(MonsterFactory.CreateVampire());

9. Which of the following is a relational operator?

+

==

?:

[]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions