Frage 1
Frage
What must be different between two overloads of a method?
Antworten
-
EITHER the number of parameters OR the return type of each method overload
-
The names of the method overloads
-
EITHER the number of parameters OR the type of at least one parameter
-
EITHER the number of parameters OR the type of at least one parameter OR the return type of each method overload
-
EITHER the names of the method overloads OR their return types
Frage 2
Frage
Which operator would you use to attach a handler to an event?
Frage 3
Frage
Which of the following is a syntactically correct way to declare and initialize an array of "int"?
Antworten
-
var x = new int[]{1, 2, 3};
-
int[] x = int[] {1, 2, 3};
-
int[3] x = new int{1, 2, 3};
-
var x = new {1, 2, 3};
Frage 4
Frage
Consider this implementation of an enumerator.
If this is enumerated, at what point will the message "In finally block!" be written to the console?
Antworten
-
It won't, the yield return bypasses the finally block.
-
Once, after the first item in the enumeration has been returned.
-
Three times, once after returning each item in the enumeration.
-
Once, after the enumeration is complete.
Frage 5
Frage
Name an advantage of passing a parameter to a method by reference, compared to passing by value
Antworten
-
Passing by reference protects the data in the caller from inadvertant changes to the parameter value inside the called method.
-
If the method throws an exception, passing by reference preserves more information in the stack trace.
-
If the parameter is large, passing by reference saves data copying and can therefore be quicker.
-
Passing by reference allows the method to safely execute on multiple threads simultaneously without risk of corrupting the data in the parameter.
Frage 6
Frage
In the following code, [System.Web.Services.WebMethod] is an example of which C# language feature?
Antworten
-
Functional Property
-
WebMethod
-
Attribute
-
Method-Setting
Frage 7
Frage
What is the main problem with the following code?
Antworten
-
The variable "ex" has been declared twice in the same context.
-
The variable "ex" is not used in the last catch block.
-
Only one "catch" block can be associated with each "try" block.
-
The last "catch" block is unreachable.
Frage 8
Frage
Write the following LINQ query using method syntax.
Antworten
-
var shortNames = names.Where(name => name.Length < 4)
.OrderBy(name => name);
-
var shortNames = names.Where(name.Length < 4)
.OrderBy(x);
-
var shortNames = names.Where(this.Length < 4)
.OrderBy(this);
-
var shortNames = names.Where(this.Length < 4)
.OrderBy(this)
.Select(this);
Frage 9
Frage
What is the full name of the "type" that is represented by keyword "long"?
Antworten
-
System.Int64
-
System.Long64
-
System.Int
-
System.Int32
-
System.Long
Frage 10
Frage
What does the "params" keyword do when used in a method parameter list?
Antworten
-
Guides the compiler in which overload of a method to choose
-
Allows arguments of any type to be passed to a method
-
Allows individual arguments to be omitted, with default values supplied, when calling the method
-
Allows a variable number of arguments to be used when a method is called
Frage 11
Frage
What happens when the below code is executed?
public interface ICar
{ public int getspeed(); }
Antworten
-
Succeed
-
Compile error
-
Warning
Frage 12
Frage
class Car
{
public void DescribeCar()
{
ShowDetails();
}
public virtual void ShowDetails()
{
System.Console.WriteLine("Standard transportation.");
}
}
class ConvertibleCar : Car
{
public new void ShowDetails()
{
System.Console.WriteLine("A roof that opens up.");
}
}
class Minivan : Car
{
public override void ShowDetails()
{
System.Console.WriteLine("Carries seven people.");
}
}
public static void TestCars1()
{
Car car1 = new Car();
car1.DescribeCar();
ConvertibleCar car2 = new ConvertibleCar();
car2.DescribeCar();
Minivan car3 = new Minivan();
car3.DescribeCar();
}
Antworten
-
Standard transportation
Standard transportation
Standard transportation
-
Standard transportation
A roof that opens up.
Carries seven people.
-
Standard transportation
Standard transportation
Carries seven people.
Frage 13
Frage
On the whole, which types can you inherit from ?
Antworten
-
Any struct or class that is not marked as sealed
-
Any class that is not marked as sealed
-
Any class
-
Any type except for the C# built-in types (int, bool, string, etc.)
Frage 14
Frage
Which of these shows the correct way to declare an extension method on "string" called "WordCount()" ?
Antworten
-
public static int WordCount (string str) : this str
{ /* ... */ }
-
public static extension int WordCount (string, string str)
{ /* ... */ }
-
public extension int string.WordCount(this string str)
{ /* ... */ }
-
public static int WordCount (this string str)
{ /* ... */ }
Frage 15
Frage
What is the visibility of the "CurrentSpeed" property in the following code ?
public class Automobile
{ double CurrentSpeed {get; set;} }
Antworten
-
Protected internal
-
Protected
-
Internal
-
Public
-
Private
Frage 16
Frage
Consider the following code.
Which of the following is true about the inner "userResponse" declaration?
Antworten
-
It will cause a compiler error because the name conflicts with the first userResponse declaration
-
It will not allocate a new variable, but will instead overwrite the contents of the outer userResponse variable.
-
It will cause a compiler error because you cannot declare local variables inside a foreach loop.
-
It will cause the outer userResponse variable to be hidden within the foreach loop.
Frage 17
Frage
What does this code illustrate?
Antworten
-
A generic collection
-
A generic method
-
A generic constraint
-
A generic type
Frage 18
Frage
How can you "modify" the "Manager" constructor declaration so that it passes its parameter to the "Employee" constructor
Antworten
-
public Manager(string name) : base(name)
{
base.ctor(name)
/* ... */
}
-
public Manager(string name) : Employee(name)
{ /* ... */}
-
public Manager(string name) : base(name)
{ /* ... */}
-
public Manager(string name)
{
Employee(name)
/* ... */
}
Frage 19
Frage
What will be the execution result of the following code ?
Antworten
-
"Hello World!" is displayed in the text block on button click
-
"Hello World!" is displayed in the text block on button click, after 1 second.
-
"Hello World!" is never displayed in the text block
-
"Hello World!" is displayed in the text block on button click, after 10 seconds
Frage 20
Frage
What will be the execution result of this code (in the console) ?
Antworten
-
Prints values from 1 to 10
-
Prints "10" - ten times
-
Throws a compiler error - as del() is not a method
-
Prints "1" - ten times
-
Throws a compiler error - as C# "List" cannot have methods in it