Solved

Consider the Following Cube Method

Question 85

Multiple Choice

Consider the following Cube method:
Static int Cube(int x)
{
Return x * x * x;
}
Which of the following statements is false


A) In C# 6, this method can be defined with an expression-bodied method as
Static int Cube(int x) = > x * x * x;
The value of x * x * x is returned to Cube's caller implicitly.
B) The symbol = > follows the method's parameter list and introduces the method's body-no braces or return statement are required. This can be used only with static methods.
C) If the expression to the right of = > does not have a value (e.g., a call to a method that returns void) , the expression-bodied method must return void.
D) Similarly, a read-only property can be implemented as an expression-bodied property. The following re-implements the IsNoFaultState property we used in the textbook to return the result of a logical expression:
Public bool IsNoFaultState = >
State == "MA" || State == "NJ" || State == "NY" || State == "PA";

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions