.Net Midterm Exam Flash Cards

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following String.Format arguments would correctly display 0.1544 as 15.44%?

"{0: 0.00}%", slacker * 100

The colors derived from these RGB values:

#FFFF00 is 255,255,0, #FF00FF is 255,0,255, and #00FFFF is 0,255,255. FF = 16x16 = 256 or 255 base 0

What is an example of a very basic LINQ query?

// To create the query, we're going to use a generic "var" type variable. var EvenQuery = from N in myNumbers // Note the lack of semi-colons here! where (N % 2) == 0 select N;

what does Console.WriteLine(String.Format("{0: ##.00}", 0.283185)); Console.WriteLine(String.Format("{0: #0.00}", 6.283185)); Console.WriteLine(String.Format("{0: 0.##}", 6)); output look like?

1. .28 2. 6.28 3. 6

What ways are we using the 'using' keyword in this class

1. Garbage collection using (Font myFont = new Font("Courier New", 18.0f)){byte charset = myFont.GdiCharSet;} 2. provide an alias to a namespace or type using Map = System.Collections.Generic.Dictionary<TKey, TValue> 3. Pulling in libraries Using System.IO;

What are the 2 ways to make a stirng nullable?

1. Nullable<string> slacker; 2. string? slacker = null; extra: int test = slacker ?? -1; // This means: if slacker is not null, set test equal to its value. If it is null, set test to -1

what does Console.WriteLine(String.Format("Pi: {0, -10: 0.00} hello", 3.14159265)); Console.WriteLine(String.Format("Pi: {0, 10: 0.00} hello", 3.14159265)); output look like?

1. PI: 3.14 hello 2. PI: 3.14 hello

Let's say I have the following enumeration defined public enum Prinny { Kurtis, Big_Sis, Fubuki, Nemo, Baal = 9999 }; What would the output from the following command be: Console.WriteLine("{0}, dood!", (Prinny) 4);

4, dood!

Which of the following arguments to a new Timer would set its interval to 5 seconds?

5000

What is an indexer?

A definition for how the subscript notation [] is used in relation to a class

What is a LinkedList?

A doubly-linked list Collection of Nodes

What is a SortedSet?

A doubly-linked list Collection, which (1) preserves sorted order as elements are added and (2) prohibits duplicate elements.

LinkedList<T>

A doubly-linked list of Nodes.

What is a delegate?

A hard-coded reference to methods that share a method signature, which can call any number of them by calling the delegate method

What is a HashSet?

A high-performance, mathematical-set container, useful for leveraging set operations such as "union" and "intersection"

What is a SortedList?

A memory-efficient Dictionary, which orders elements by their "key"

What is a Property?

A public facing attribute, typically controlling read/write access to private attributes

What is an event?

A representation of an action taken by a user

What is a predicate?

A single-purpose delegate, used to generate a true/false value, based on programmer-defined logic

What is an interface?

An abstract class containing exactly one method to be defined by other classes

In relation to nullable data types, what does the ?? notation represent?

An alternate assignment, should a nullable variable be equal to null.

What is a List?

An automatically re-sizing array

What is a SortedDictionary?

An insert/remove-efficient Dictionary, which orders elements by their "key"

What is a Dictionary?

An oversized array where a "key" is used to generate an index where a "value" will be stored

How are relational comparisons of strings done?

By checking the return value of "CompareTo(string alpha)"

"int slacker[2, 2]" is an example of which type of array?

Conventional, multi-dimensional arrays

List<T>

Functionally, an array. Not to be confused with a linkedlist.

What is the value of ten in Enum Doctor= { Hello, sup, how, are = 1000, ten}

Hello = 0, sup = 1, how = 2, are = 1000, ten = 1001

Which interface allows for arrays/collections of objects from a class, to be sorted?

IComparable

Which interface allows for Collections to be iterated through by foreach loops?

IEnumerable

Which of the following interfaces allows for non-trivial collections (i.e. not arrays) to be iterated by foreach loops?

IEnumerable

Example of a checkbox?

If (Checkbox.checked == true)

Give two examples of possible exceptions?

IndexOutOfRangeException, DivideByZeroException, NullPointerException, IOException, EndOfStreamException

The following: Infint palindromicPrime = "399878993"; object intermid = palindromicPrime; Infint slacker = (Infint)intermid;is an example of what?

Its boxing, which essentially is converting a value type (char, int, etc) to a object or Reference type.

"int slacker[2][2]" is an example of which type of array?

Jagged arrays

Which of the following best describes how a SortedList collection functions?

Like a memory-efficient Dictionary, that orders the elements within.

What are the two types of events we've worked with the most so far?

Mouse events and keyboard events

Provide the correct order of MouseEvents, triggered by a complete click of a mouse button.

MouseDown Click MouseClick MouseUp

What is an exception?

Objects that are created if a specific (typically negative) event occurs during program execution

How do you define variables to possibly contain the value null?

Placing a ? after the date type or Nullable<T>

What terms do we use to describe the two actors involved with events?

Publishers and subscribers

Which of the following is the correct declaration (and default initialization) of a 3 x 3 x 3-dimensional array of Slacker objects?

Slacker[ , , ] myArray = new Slacker[3, 3, 3];

How do you call a string builder method?

StringBuilder changes = new StringBuilder(convert); // "deadlift" some extra bits to also learn changes.Replace('d', 'D', 0, 1); // Swap the 'd' character found at the beginning with 'D' changes.Append(" is the best!"); // "Deadlift is the best!" (Do you even lift, bro?)

Dictionary<TKey, TValue>

The "T" before Key and Value mean that their data type is generic. This is functionally a Map or HashMap container from other programming languages.

What does the ?? notation represent?

The conditional assignment if a nullable type is being used

What is a Static method?

There will not a exist a instantiation of this class in my program ex: Classname.attr; but not classname slacker = new slacker();

What is a delegate?

They're hard-coded references to a class of methods that share a signature. "Signature" here meaning methods that have the same return type and argument list. all the same signature void doingStuff(string, int); void moreStuff(string, int); void stuffAndThings(string, int); public delegate void ActionJackson(string, int); then use it like ActionJackson toDoList; toDoList += doingStuff; // Makes "toDoList" call "doingStuff" when given arguments toDoList += moreStuff; toDoList += stuffAndThings; This line of code can then be called to print all 3 instead of calling 3 sperate methods. toDoList("Print ALL the things!", 42);

What is a virtual method?

This method may be overridden by derived classes.

What is a abstract method?

This method must have an implementation in all derived classes.

SortedList<TKey, TValue>

This one's unusual. Despite the name, this is functionally more similar to a sorted Dictionary (which is implemented with SortedDictionary), as the element pairs of this container are continuously sorted by their TKey values. SortedList collections use less memory, but don't insert/remove as quickly as SortedDictionaries, but are superior when initialized with all the data at once. Not to be confused with sorted set.

The following code: string input = "And then one warm summer night I'll hear fireworks outside"; Console.WriteLine(String.Format("The fourth token is '{0}'.", input.Split()[3])); Will (1) not generate a compilation error and (2) print The fourth token is 'warm'.

True

HashSet<T>

Which is a high-performance set container (without ordering the elements within), most useful when you are leveraging mathematical set operations, such as unions and intersections. These operations will change the original HashSet, as opposed to many other types of set operations which return a new set of results (or an empty set), based on the operation.

SortedSet<T>

Which is functionally similar to a LinkedList collection, that (1) inserts new elements to maintain sorted order and (2) prohibits the inclusion of duplicate entries.

Queue<T>

Your run-of-the-mill, FIFO queue container.

What is a Queue?

Your run-of-the-mill, FIFO stack container

What is a Stack?

Your run-of-the-mill, LIFO stack container

Stack<T>

Your run-of-the-mill, LIFO stack container.

Assuming my Form is "listening" for keyboard events, how would CTRL + SHIFT + A be coded as?(My KeyEventArgs object is called alpha in the responses below)

alpha.Control == true && alpha.Shift == true && alpha.KeyCode == Keys.A

Which of the following would be the correct syntax for calling a parent class' public virtual void print() method?

base.print();

Out?

does not have a defined value int second; myOutMethod(out second); // note the "out" keyword usage here public void myOutMethod(out int alpha) { alpha = 216; }

Ref?

has a defined value int first = 100; myRefMethod(ref first); // note the "ref" keyword usage here public void myRefMethod(ref int alpha) { alpha = 27; }

Example of a dropdown list?

if(slacker.selectindex != -1) { console.writeline(slacker.selectitem.tostring()); }

how to call IComparable?

int CompareTo(Object alpha);

provide a example of boxing and unboxing int taxicab = 1729;

int taxicab = 1729; object slacker = taxicab; // This "boxes" slacker into an integer type int slackest = (int)slacker; // This "unboxes" the slacker, // possible only because it was previously "boxed"

What does a normal array look like?

int[] second = new int[5] { 0, 1, 2, 3, 4 }; // initial array values

What does a jagged array look like?

int[][] jaggedArray = new int[3][]; // Three integer arrays of yet undefined sizes

What are the two arguments we've typically used for event handlers?

object Alpha, EventArgs Beta

How do you define an indexer?

public <returnType> this[int index]

Refer back to our Community and Real Estate class structures from Assignment 1. Let's say I want to include an indexer for my Community class to refer to one of the People within. Which of the following would be the correct header for this?

public People this[int index] { /* get and set */ }

How do you initialize a class and call the parent?

public Slackest() : base() // Help initialize by calling the base class default constructor base.Slackest();

What is a basic initialization of a indexer?

public Student this[int index] { //just make sure its get and setting something get { return enrolled[index]; } set { enrolled[index] = value; } } the most important part is knowing Public Library this[int index]

Give an example of a Exception.

public class MyNewException : Exception // Deriving from the "Exception" base class { public override string ToString() { return "This is the new error message, for MyNewException"; } }

Give an example of building properties.

public string Name => Last + ", " + First; public string CourseListing => Dept + " " + Number;

What is the method header for an event?

public void myButton_ClickEvent(Object sender, EventArgs args)

When passing arguments by reference, which of the two methods will NOT require the argument to contain an initial value?

public void slacker(out int alpha)

What is a predicate?

returning a boolean value, and taking exactly one argument — the argument type can be anything, though public delegate bool Predicate<T>(T alpha); Predicate<Student> myPredicate = (Student alpha) => { System.Console.WriteLine("I don't know what all to do here."); System.Console.WriteLine("But I'm doing more than one thing."); };

Give an example of a parameter array? int[] myArray = { 0, 1, 2, 3, 4 }; // myArray will then contain 100, 101, 102, 103, 104 // "array" == { 1, 2, 3 } (although not meaningfully returned)

simpleAdd(100, myArray); simpleAdd(5, 1, 2, 3); public void simpleAdd(int increment, params int[] array) { for (int i = 0; i < array.Length; i++) array[i] += increment; }

I have a public void method called slacker that takes a single, parameter array of integers as an argument. Which of the following method calls is NOT valid? int[] arguments = {1, 8, 27, 64}; slacker(arguments);

slacker();

Give two examples of reference type variables.

strings, Collections, objects from a class, delegates, or pointers to dynamically allocated memory

What is an example of group by in a LINQ query?

var GPAByYearQuery = from student in MyClass group student by student.Year orderby student.GPA Ascending; // Note the missing "select N" statement from the above queries


संबंधित स्टडी सेट्स

Animal Science Companion Animals

View Set

Forensic science Unit 1 Review Questions

View Set

Ch 11 Drinking Alcohol Responsibility

View Set

Chapter 5: Cost-Volume-Profit Relationships

View Set

Chapter 12: Federally Subsidized Programs that Supply Food for People in the U.S.

View Set

Physical Science 1 Ch 3 Homework

View Set

1st Semester Exam Review (Language Arts)

View Set

Spanish 2: ¿CUÁNTO CUESTA/N? (ropa y números) (10)

View Set

Chapter 13: Weathering and Slopes

View Set