Question 41 Type Methods Called Without Instantiating Object First Static Dynamic Primary Q29139145

Question 41

What type of methods can be called without instantiating anobject first?

static
dynamic
primary
No answer text provided.

Question 42

Assume an extension method is defined as:

static class Util

{     public static int Negate(this int i)    

{         

return -i;     

}

}

Which of the following is correct?

int x = 591;

Console.WriteLine($”x.Negate {x.Negate()}”);

int x = 591;

Console.WriteLine($”x.Negate {Util.Negate(x)}”);

both A and B
None of the above

Question 43

To define an extension method for a type:

The extension method can be an instance method
The first parameter must be of the type being extended
The first parameter must be proceeded by this keyword
Both A, B and C

Both B and C

Both A and C

Question 44

var addresses = new[] {

new { CompanyName = “Alpine Ski House”, City = “Berne”, Country= “Switzerland”},

new { CompanyName = “Coho Winery”, City = “San Francisco”,Country = “United States”},

new { CompanyName = “Wingtip Toys”, City = “London”, Country =”United Kingdom”},

new { CompanyName = “Wide World Importers”, City = “Tetbury”,Country = “United Kingdom”}

};

var usCompanies =     

addresses.Where(addr => String.Equals(addr.Country, “UnitedStates”))             

.Select(usComp => usComp.CompanyName)

What type is variable usCompanies?

int
string
IEnumerable<string>
anonymous type

Question 45

In the variable declaration Func<Order>processor, the variable processor representswhich of the following?

Methods that take no parameters and return an Orderobject.
Methods that take an Order object as a parameter and returnvoid.
Methods that take an Order object as a parameter and return anOrder object.
Methods provided by the Action class that take no parametersand return void.
None of the choices are correct

Question 46

Assume Horse class is defined as:

class Horse : ILandBound, IJourney

{

int ILandBound.NumberOfLegs()     {        return 4;    }     

int IJourney.NumberOfLegs() {        return 3;    }

}

Which of the following is correct if:

Horse horse = new Horse();
int legs = horse.NumberOfLegs();

legs variable has a value of 4
legs variable has a value of 3
Code will not compile
None of the choices are correct

Question 47

Suppose the variable result is declared by thestatement Func<float, float> result. Which of thefollowing correctly initializes result to an expression lambda?

result = (float x) => x * x;
result = (x) => return x * x;
result = x => x * x;
Both a and c are correct.

Question 48

Which method can you use to find the minimum value in asequence?

(from i in myArray select i).Min()

from Min(i) in myArray select i
from i in myArray select Min(i)
from i in Min(myArray) select i

Question 49

Which object does the variable mySet inherit from?

Int[] mySet = new int[5];

System.Collection
System.Collection.List
System.Array
None, this is a value type.

Question 50

If Employee inherits from Person andManager inherits from Employee, which of thefollowing statements is valid?

Person alice = new Employee();
Employee bob = new Person();
Manager cindy = new Employee();
Manager dan = (Manager)(new Employee());
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *