Programming in C# Chapter 3 Review Questions

Ace your homework & exams now with Quizwiz!

Which of the following identifiers follows the standard naming convention for a method? a. Calculate Final Grade b. MilesPerGallon c. InValueMethod d. PrintReport e. Method1

PrintReport

What is the signature of the following method? public void SetNoOfSquareYards(double squareYards) a. public void SetNoOfSquareYards(double squareYards) b. public SetNoOfSquareYards(double squareYards) c. SetSetNoOfSquareYards d. public SetNoOfSquareYards(double) e. SetNoOfSquareYards(double)

SetNoOfSquareYards(double)

Given the following statement, what would be the best heading for the DetermineAnswer( ) method? int aValue, result; result = DetermineAnswer(27.83, aValue); a. public void DetermineAnswer(27.83, aValue); b. public int DetermineAnswer( ); c. public int DetermineAnswer(double v1, int v2); d. public double int DetermineAnswer( ); e. public void DetermineAnswer(double v1, int v2);

public int DetermineAnswer(double v1, int v2)

Given the call to the method ComputeCost( ) shown below, which of the following would be the most appropriate heading for the method? The variable someValue is declared as an int. someValue = ComputeCost(27.3); a. public static void ComputeCost(double aValue) b. public static int ComputeCost( ) c. public static double ComputeCost(int someValue) d. public static int ComputeCost(double aValue) e. public static int ComputeCost(int aValue)

public static int ComputeCost(double aValue)

Which of the following is a valid method call for DetermineHighestScore? void DetermineHighestScore(int val1, int val2) a. void DetermineHighestScore(int val1, int val2) b. DetermineScore(int val1, int val2) c. DetermineHighestScore(val1, val2) d. DetermineHighestScore(2, 3.5) e. GetHighestScore( )

DetermineHighestScore(val1, val2);

Which of the following would be a valid call to a method defined as shown below? public static void InitializeValues( ) a. void InitializeValues( ); b. Console.WriteLine( InitializeValues( ) ); c. int returnValue = InitializeValues( ); d. InitializeValues( ); e. InitializeValues(aVariable);

InitializeValues( );

Which of the following would be the most appropriate way to invoke the predefined Floor( ) method found in the Math class? public static double Floor(double) a. answer = Floor(87.2); b. answer = Math.Floor(87.2); c. Floor(87.2); d. Math.Floor(double); e. Math.Floor(87.2);

answer = Math.Floor(87.2);

After completing the called method's body, control is returned: a. back to the location in the calling method that made the call b. to the last statement in the method that made the call c. to the first statement in the method that made the call d. to the Main( ) method e. to the method that is listed next in the printed source code

back to the location in the calling method that made the call

The following is probably an example of a _______________. DisplayInstructions( ); a. call to a value-returning method b. call to a void method c. method heading d. method definition e. call to a method with multiple arguments

call to a void method

If you follow the standard C# naming conventions, the local variable names: a. follow the Camel case convention b. should use an action verb phrase c. begin with an uppercase character d. are named like namespace identifiers e. are defined inside parenthesis of the method header

follow the Camel case convention

If a method is to be used to enter two values that will be used later in the program, which of the following would be the most appropriate heading and call? a. heading: public void InputValues(out int val1, out int val2) call: InputValues(out val1, out val2); b. heading: public void InputValues(int val1, int val2) call: InputValues(val1, val2); c. heading: public void InputValues(ref int val1, ref int val2) call: InputValues(ref val1, ref val2); d. heading: public int int InputValues( ) call: val1 = InputValues( ); val2 = InputValues( ); e. none of the above

heading: public void InputValues(out int val1, out int val2) call: InputValues(out val1, out val2);

Which of the following is NOT a modifier in C#? a. int b. private c. public d. static e. protected

int

Variables needed only inside a method should be defined as _______________. a. private member data b. local variables c. properties d. arguments e. parameters

local variables

Functions or modules found in other languages are similar to ____________ in C#. a. modifiers b. parameters c. arguments d. methods e. classes

methods

Which of the following modifiers is the most restrictive? a. private b. static c. public d. internal e. protected

private

Given the following task, which would be the most appropriate method heading? Results have been calculated for taxAmount and totalSales. Write a method heading that accepts these values as input for display purposes. a. public static DisplayResults( ) b. public DisplayResults(double) c. public static void DisplayResults( ) d. public static void DisplayResults(double taxAmount, double totalSales) e. public static void DisplayResults(taxAmount, totalSales)

public static void DisplayResults(double taxAmount, double totalSales )

Given the following task, which would be the most appropriate method heading? A method displays three integer values formatted with currency. a. public static int int int DisplayValues( ) b. public static int DisplayValues(int v1, int v2, int v3) c. public static void DisplayValues( ) d. public static void DisplayValues(int v1:C, int v2:C, int v3:C) e. public static void DisplayValues(int v1, int v2, int v3)

public static void DisplayValues(int v1, int v2, int v3)

Given the following method definition, what would be a valid call? The variable someIntValue is defined as an int. public static int GetData(out int aValue, out ref bValue) a. someIntValue = GetData(aValue, bValue); b. someIntValue = GetData(out aValue, ref bValue); c. someIntValue = GetData(out, ref); d. someIntValue = GetData(int out aValue, int ref bValue); e. GetData(out aValue, ref bValue);

someIntValue = GetData(out aValue, ref bValue);

Given the following task, which would be the most appropriate method heading? A method receives three whole numbers as input. The values represent grades. They should be unchangeable in the method. The method should return the average with a fractional component. a. static double DetermineGrade(int grade1, int grade2, int grade3) b. static int DetermineGrade(int grade1, int grade2, int grade3) c. static int int int DetermineGrade(double finalAverage) d. static double DetermineGrade(ref int grade1, ref int grade2, ref int grade3) e. static void DetermineGrade( )

static double DetermineGrade(int grade1, int grade2, int grade3)

Which of the following is placed in a method heading to indicate that no value will be returned? a. public b. static c. arguments d. void e. return

void


Related study sets

Disability and the Law Test 4 (ch13 & ch14)

View Set

AP Gov Voter Behavior APQ, AP Gov Voter Behavior Pre-Test

View Set

SCIN 111 Exam 2 - Chapters 6,7,8, and 9

View Set

Unit 5 Interpersonal IPA example Q &A

View Set

Amino Acids, Amino Acids, Chembio exam 1

View Set

NURS 3107 - Exam 4 - EAQs: Integumentary Assessment, Ch. 24 NCLEX Practice, DavisEdge Quiz: Nursing Care of Patients with Skin Disorders

View Set

Network Security (Version1.0) - Final Exam

View Set

PMP - 2020 - Quiz - PpK - Knowledge Area - Risk Management

View Set