C Sharp MCQ Quiz Answered

1. (TCO 8) Which words belong in the blank to indicate that the method PutFiles() returns a double value to the calling method, and that only the class containing PutFiles() is allowed to call it?

_____ PutFiles() (Points : 3)
private static double
public static double
private static void
public static void

2. (TCO 8) Which is a correct heading for a method that accepts three doubles and returns their sum? (Points : 3)
public static void Add(double num1, num2, num3);
public static Add(double num1, double num2, double num3);
public static double Add(double num1, double num2, double num3);
public static sum Add(double num1, double num2, double num3);

3. (TCO 8) Suppose your code has two variables declared as:

double myNumber = 2.17;
int myInt = 6;

Which of the following would be a legal call to this method:

public static double getWidgets(int num1, double num2) (Points : 3)
double getWidgets(myInt, myNumber);
getWidgets (myInt, myNumber);
myInt = getWidgets(myNumber);
double newWidget = getWidgets(myInt, myNumber);

4. (TCO 7) Which is a valid overloaded version of this method:

char CalculateGrade(double val1, double val2) (Points : 3)
char CalculateGrade(int val1)
char CalculateMyGrade(int val1, double val2)
char CalculateMyGrade(double val1)
double CalculateGrade(double val1, double val2)

5. (TCO 7) Which is not a valid name for a method or function? (Points : 3)
MyMod5
mod_1
mod_@7
MyMod_7

6. (TCO 8) The following method has _____ input parameter(s) and returns _____ to the calling method.

Public static void GetResult(int value1, double value2) (Points : 3)
2, an integer
2, no value
an integer, an integer
1, an integer

7. (TCO 7) Why is it not necessary to pass a global variable to a method? (Points : 3)
You do have to pass global variables to methods.
Main() passes them for you.
They are passed automatically.
All methods can access globally declared variables.

8. (TCO 8) Because Main() and testMeth() store myVar in _____, the output of this code will be _____.

static void
Main()
{
int myVar = 6;
Console.Write("{0} ", myVar);
myVar++;
testMeth(myVar);
Console.Write("{0} ", myVar);
Console.Read();
}

public static void testMeth(int
myVar)
{
Console.Write("{0} ", myVar);
myVar++;
}

(Points : 3)
different memory locations, 6 7 7
the same memory location, 6 7 7
different memory locations, 6 7 8
the same memory location, 6 7 8

9. (TCO 8) Because Main() and testMeth() store myVar in _____, the output of this code will be _____.

static void
Main()
{
int myVar = 6;
Console.Write("{0} ", myVar);
myVar++;
testMeth(ref myVar);
myVar++;
Console.Write("{0} ", myVar);
Console.Read();
}

public static void testMeth(ref int myVar)
{
Console.Write("{0} ", myVar);
myVar++;
}

(Points : 3)
different memory locations, 6 7 8
the same memory location, 6 7 8
different memory locations, 6 7 9
the same memory location, 6 7 9

10. (TCO 7) Which is not a Predefined C# method? (Points : 3)
Console.GetLine();
Console.Read();
Math.Abs();
Math.Cos();

11. (TCO 8) Write a C# program to calculate 2% interest on a savings account balance. Main() stores a balance of $1000.00 in an appropriate variable and passes it by-value to a method called “calcInterest.” calcInterest calculates the interest and returns it to Main() by-value. (Note: interest = .02 * balance). Main() prints out the balance and the interest. (Points : 5)

Download Full Solution : Click HERE for all Answers

TYPE SOME PART OF QUESTION YOU ARE LOOKING FOR

.

.
acc week