Programming in C# Certification 70-483 Q&A

Description

Work in progress!
Khrystal Colon
Flashcards by Khrystal Colon, updated more than 1 year ago More Less
Richard Brown
Created by Richard Brown almost 9 years ago
Khrystal Colon
Copied by Khrystal Colon about 4 years ago
0
0

Resource summary

Question Answer
What is the result of this expression if both a and b are true? a ^ b False. This is the bitwise OR operator which returns True only when just one of the operands is True
What is the syntax using the ternary operator which could replace this statement? return (a == b) ? c : d;
Which of these statements is true regarding a 'switch' statement? 1) the 'default' statement is optional 2) each 'case' statement must contain a 'break' 3) you can use more than one 'case' statement to test for a particular value 4) the code after each 'case' statement must be contained in parentheses Only 1 is true. 2 is false - each statement need not contain a break, however you cannot execute code under one 'case' statement and then flow directly into the next 'case' statement. So you need to have something to stop flow continuing such as a break but also a goto, return or infinite loop would compile. 4 is false - the parentheses are optional. The compiled code is no different if they are included or not.
What is the signature of a method named 'square' which extends the int data type? public static int square(this int num) Extension methods must be in a static class, with the type being extended the first parameter to the method, preceded by the 'this' keyword
What does the modifier 'virtual' indicate about a method? That is can be overridden in a derived class
What is the signature of an indexed property for a class which contains an internal collection of ints? public int this[int i] The 'this' keyword makes the property indexed
What is boxing? The process of casting a value type to a reference type. A value type is put inside a new object on the heap and a reference to it stored on the stack
What is unboxing? The process of casting an object to a value type. The object is taken from the heap and stored in a value type on the stack
What is the intern pool? A table maintained by the CLR which holds a reference to each unique text value used by an assembly. A string variable referring to a piece of text actually refers to the intern pool. If multiple variables have the same value they refer to the same entry in the intern pool.
What is the maximum number of parent classes which a class can inherit from? One, multiple inheritance is not supported by C#.
What interface should be implemented to allow two instances of a class to be compared to one another? IEquatable, which requires that an 'Equals' method be implemented.
What interface should be implemented to allow a copy of a class to be produced? ICloneable, which requires that a 'Clone' method be implemented. Clone returns an object so calling code must cast this appropriately.
Which looping construct should you use when you know the number of items in a collection and you need to remove some items from the collection? for should be used, though you need to make sure the index value is correct after removing items. foreach cannot be used as it does not allow the collection to be changed whilst iterating.
You have a variable which you want to check for a null value. If the value is not null you want to execute a method on the variable. What technique performs best for this? Short-circuiting. This is where the runtime will only evaluate the right hand side of an equality operator if the left hand side is true. The code for this could be something such as: var result = (x != null) && GetSquare(x) // Do something
Which of these describes contravariance with respect to a method that is assigned to a delegate? 1. The method accepts a parameter that is a base class of the parameter type defined in the delegate. 2. The method returns a type that is derived from the delegate's return type. Option 1.
Which of these describes covariance with respect to a method that is assigned to a delegate? 1. The method accepts a parameter that is a base class of the parameter type defined in the delegate. 2. The method returns a type that is derived from the delegate's return type. Option 2.
What are the signatures of: - a method Add which accepts two int parameters and returns an int? - a delegate of this method? - a variable of the delegate type? private int Add(int x, int y); private delegate int AddDelegate(int x, int y); private AddDelegate MyFunction;
What two delegate types are build into the .NET Framework? What can each be used for and how many parameters do they accept? Action and Func. Action represents a method that returns void. It has overloads that accept from 0 to 18 parameters. Func represents a method that returns a value. It also has overloads that accept from 0 to 18 parameters.
Which looping construct ends with a semi-colon and executes at least once? do while
By default, what type are parameters to a method Value types - so a new storage location is created in memory for the parameter. Note that object references are passed by value by default.
What would this output? False True The parameter to Foo is a value parameter and its value is the reference to memory where the value is held. Therefore setting it to null just removes that memory reference and is not reflected in the invocation. Note that changing the data in the object that is referred to will be seen by the invocation e.g. appending more data to the string in this instance. The parameter to Bar is passed by reference so changes are reflected in the invocation.
Show full summary Hide full summary

Similar

HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Historical Development of Computer Languages
Shannon Anderson-Rush
Useful String Methods
Shannon Anderson-Rush
What is a Computer?
cscutt
Programming in C# Exam 70-483 Q&A
dino.in
Flvs foundations of programming dba 2
mariaha vassar
Programming Goals: Creating a Learning Map for C#
Garrett Fortner
C# Fundamentals
Robert Mulpeter
Programming in C#
Любовь Лось
Python Quiz
karljmurphy
computer systems and programming quiz
Molly Batch