GoConqr has a new look! Let us know what you think.

Flashcards

Programming in C# Exam 70-483 Q&A

Richard Brown C# Microsoft C# 70-483 English 4.0Average rating 4.0 out of 5 (3 ratings) 21 cards

Programming in C# Exam 70-483 Q&A

Cards in this deck (21)

  1. 1What is the result of this expression if both a and b are true? a ^ bFalse. This is the bitwise OR operator which returns True only when just one of the operands is True
  2. 2What is the syntax using the ternary operator which could replace this statement?return (a == b) ? c : d;What is the syntax using the ternary operator which could replace this statement?
  3. 3Which 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 parenthesesOnly 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.
  4. 4What 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
  5. 5What does the modifier 'virtual' indicate about a method?That is can be overridden in a derived class
  6. 6What 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
  7. 7What 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
  8. 8What 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
  9. 9What 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.
  10. 10What is the maximum number of parent classes which a class can inherit from?One, multiple inheritance is not supported by C#.
  11. 11What 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.
  12. 12What 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.
  13. 13Which 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.
  14. 14You 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
  15. 15Which 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.
  16. 16Which 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.
  17. 17What 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;
  18. 18What 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.
  19. 19Which looping construct ends with a semi-colon and executes at least once?do whileWhich looping construct ends with a semi-colon and executes at least once?
  20. 20By default, what type are parameters to a methodValue types - so a new storage location is created in memory for the parameter.
    Note that object references are passed by value by default.
  21. 21What 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.
    What would this output?

Information

Description
Work in progress!
Created by
Richard Brown
Views
203
Rating
Average rating 4.0 out of 5 (3 ratings)

Feedback

What is it about?

What do you think of the new look?

How do you like it?