Questão 1
Questão
What must be different between two overloads of a method?
Responda
-
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
Questão 2
Questão
Which operator would you use to attach a handler to an event?
Questão 3
Questão
Which of the following is a syntactically correct way to declare and initialize an array of "int"?
Responda
-
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};
Questão 4
Questão
Consider this implementation of an enumerator.
If this is enumerated, at what point will the message "In finally block!" be written to the console?
Responda
-
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.
Questão 5
Questão
Name an advantage of passing a parameter to a method by reference, compared to passing by value
Responda
-
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.
Questão 6
Questão
In the following code, [System.Web.Services.WebMethod] is an example of which C# language feature?
Responda
-
Functional Property
-
WebMethod
-
Attribute
-
Method-Setting
Questão 7
Questão
What is the main problem with the following code?
Responda
-
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.
Questão 8
Questão
Write the following LINQ query using method syntax.
Responda
-
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);
Questão 9
Questão
What is the full name of the "type" that is represented by keyword "long"?
Responda
-
System.Int64
-
System.Long64
-
System.Int
-
System.Int32
-
System.Long
Questão 10
Questão
What does the "params" keyword do when used in a method parameter list?
Responda
-
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
Questão 11
Questão
What happens when the below code is executed?
public interface ICar
{ public int getspeed(); }
Responda
-
Succeed
-
Compile error
-
Warning
Questão 12
Questão
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();
}
Responda
-
Standard transportation
Standard transportation
Standard transportation
-
Standard transportation
A roof that opens up.
Carries seven people.
-
Standard transportation
Standard transportation
Carries seven people.
Questão 13
Questão
On the whole, which types can you inherit from ?
Responda
-
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.)
Questão 14
Questão
Which of these shows the correct way to declare an extension method on "string" called "WordCount()" ?
Responda
-
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)
{ /* ... */ }
Questão 15
Questão
What is the visibility of the "CurrentSpeed" property in the following code ?
public class Automobile
{ double CurrentSpeed {get; set;} }
Responda
-
Protected internal
-
Protected
-
Internal
-
Public
-
Private
Questão 16
Questão
Consider the following code.
Which of the following is true about the inner "userResponse" declaration?
Responda
-
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.
Questão 17
Questão
What does this code illustrate?
Responda
-
A generic collection
-
A generic method
-
A generic constraint
-
A generic type
Questão 18
Questão
How can you "modify" the "Manager" constructor declaration so that it passes its parameter to the "Employee" constructor
Responda
-
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)
/* ... */
}
Questão 19
Questão
What will be the execution result of the following code ?
Responda
-
"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
Questão 20
Questão
What will be the execution result of this code (in the console) ?
Responda
-
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