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

Quiz

C# - Test Drive...!!

Prashant Singh R 20 questions 5.0 (1 rating)

Take the quiz

This quiz has a time limit, so it opens in the usual player.

Questions in this quiz (20)

  1. 1What must be different between two overloads of a method?
    1. AEITHER the number of parameters OR the return type of each method overload
    2. BThe names of the method overloads
    3. CEITHER the number of parameters OR the type of at least one parameter
    4. DEITHER the number of parameters OR the type of at least one parameter OR the return type of each method overload
    5. EEITHER the names of the method overloads OR their return types
  2. 2Which operator would you use to attach a handler to an event?
    1. A=
    2. B=+
    3. C+=
    4. D=>
    5. E->
  3. 3Which of the following is a syntactically correct way to declare and initialize an array of "int"?
    1. Avar x = new int[]{1, 2, 3};
    2. Bint[] x = int[] {1, 2, 3};
    3. Cint[3] x = new int{1, 2, 3};
    4. Dvar x = new {1, 2, 3};
  4. 4Consider this implementation of an enumerator.
    If this is enumerated, at what point will the message "In finally block!" be written to the console?
    Image for question 4
    1. AIt won't, the yield return bypasses the finally block.
    2. BOnce, after the first item in the enumeration has been returned.
    3. CThree times, once after returning each item in the enumeration.
    4. DOnce, after the enumeration is complete.
  5. 5Name an advantage of passing a parameter to a method by reference, compared to passing by value
    1. APassing by reference protects the data in the caller from inadvertant changes to the parameter value inside the called method.
    2. BIf the method throws an exception, passing by reference preserves more information in the stack trace.
    3. CIf the parameter is large, passing by reference saves data copying and can therefore be quicker.
    4. DPassing by reference allows the method to safely execute on multiple threads simultaneously without risk of corrupting the data in the parameter.
  6. 6In the following code, [System.Web.Services.WebMethod] is an example of which C# language feature?Image for question 6
    1. AFunctional Property
    2. BWebMethod
    3. CAttribute
    4. DMethod-Setting
  7. 7What is the main problem with the following code?Image for question 7
    1. AThe variable "ex" has been declared twice in the same context.
    2. BThe variable "ex" is not used in the last catch block.
    3. COnly one "catch" block can be associated with each "try" block.
    4. DThe last "catch" block is unreachable.
  8. 8Write the following LINQ query using method syntax.Image for question 8
    1. Avar shortNames = names.Where(name => name.Length < 4)
      .OrderBy(name => name);
    2. Bvar shortNames = names.Where(name.Length < 4)
      .OrderBy(x);
    3. Cvar shortNames = names.Where(this.Length < 4)
      .OrderBy(this);
    4. Dvar shortNames = names.Where(this.Length < 4)
      .OrderBy(this)
      .Select(this);
  9. 9What is the full name of the "type" that is represented by keyword "long"?
    1. ASystem.Int64
    2. BSystem.Long64
    3. CSystem.Int
    4. DSystem.Int32
    5. ESystem.Long
  10. 10What does the "params" keyword do when used in a method parameter list?
    1. AGuides the compiler in which overload of a method to choose
    2. BAllows arguments of any type to be passed to a method
    3. CAllows individual arguments to be omitted, with default values supplied, when calling the method
    4. DAllows a variable number of arguments to be used when a method is called

Information

Description
A small test drive - to evaluate a few important concepts from C#
Language
English
Views
251
Tags
c#evaluationoopsengineeringpmp
Rating
5.0 out of 5 · 1 rating
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?