Question
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
List
There is no advantage.
It is easier to iterate over all of the elements of a List
2. What does this code print?
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.Add(CreateFrankenstein());
monsters.Add(CreateVampire());
List
monsters.Add(MonsterFactory.CreateFrankenstein());
monsters.Add(MonsterFactory.CreateVampire());
List
monsters.Add("Franken Berry");
monsters.Add("Count Chocula");
List
monsters.Add(CreateFrankenstein());
monsters.Add(CreateVampire());
List
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started