Chapter 4
C# Programming: From Problem Analysis to Program Design · 21 exercises
Problem 1
. a. modifiers b. parameters c. arguments d. methods e. classes # Functions or modules found in other languages are similar to ______________ in C#. a. modifiers b. parameters c. arguments d. methods e. classes
4 step solution
Problem 2
Which of the following is placed in a method heading to indicate no value will be returned? a. public b. static c. arguments d. void e. return
4 step solution
Problem 3
Which of the following modifiers is the most restrictive? a. private b. static c. public d. internal e. protected
7 step solution
Problem 5
Which of the following would be the most appropriate way to invoke the predefined Floor \((\quad)\) method found in the Math class? public static double Floor (double) a. answer \(=\quad\) Floor (87.2) b. answer \(=\quad\) Math. Floor (87.2) c. Floor (87.2) d. Math.Floor (double); e. Math.Floor (87.2)
4 step solution
Problem 6
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)
4 step solution
Problem 7
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
4 step solution
Problem 8
Which of the following is a valid overloaded method for DetermineHighestscore? int DetermineHighestscore(int vall, int val2) a. void DetermineHighestscore (int val1, int val2) b. int DetermineScore(int vall, int val2) c. void DetermineHighestscore (double val1, double val2) d. double DetermineHighestscore(int vall, int val2) e. int GetHighestscore(int vall, int val2)
3 step solution
Problem 9
What is the signature of the following method? public voidƒSetNoOfSquareYards(doubleƒsquareYards) { ƒƒƒƒƒƒƒnoOfSquareYardsƒ=ƒsquareYards; } a. public void SetNoOfSquareYards(double squareYards) b. public SetNoOfSquareYards(double squareYards) c. SetNoOfSquareYards d. public SetNoOfSquareYards(double) e. SetNoOfSquareYards(double)
4 step solution
Problem 10
Instance variables are the same as: a. private member data b. local variables c. properties d. arguments e. parameters
4 step solution
Problem 11
Given the Employee class shown below, which of the following would be the most appropriate heading for its default constructor? What would the heading for a constructor for the following class look like? public class Employee a. public void Employee( b. public Employee( ) c. public static Employee( d. private void Employee ( ) e. private Employee ( )
4 step solution
Problem 12
The following is probably an example of a ____________________ public double GetYards ( ) a. constructor b. mutator c. property d. accessor e. class definition
3 step solution
Problem 13
naming conventions, the property name for the following instance variable would be: private string name; a. propertyname b. nameProperty c.… # If you follow the standard C# naming conventions, the property name for the following instance variable would be: private string name; a. propertyname b. nameProperty c. getName d. name e. Name
3 step solution
Problem 15
Given the following class definition, what would be a valid heading for a mutator? public class student private string name; private double gpa; a. public double SetGpa (double gpavalue) b. public void setGpa (double gpavalue) c. public double SetGpa( d. public void GetGpa (double gpavalue) e. public double SetGpa (
3 step solution
Problem 16
If a method is to be used to enter two values, 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
7 step solution
Problem 17
? a. const b. Private c. public d. static e. protected # Which of the following is not a modifier in C#? a. const b. Private c. public d. static e. protected
4 step solution
Problem 18
Normally, member data uses a ____________ access modifier, and methods use a __________ access modifier for object-oriented solutions. a. protected public b. private protected c. public protected d. public private e. private public
4 step solution
Problem 19
Given the following task, which would be the most appropriate class 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. double 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( )
5 step solution
Problem 20
Given the following task, which would be the most appropriate class method heading? Results have been calculated for taxAmount and totalsales.Write a class method heading that accepts these values as input for display purposes. a. public static DisplayResults ( ) b. public DisplayResults ( ) c. public static void DisplayResults ( ) d. public static void DisplayResults (double taxAmount, double totalsales e. public static void DisplayResults (taxAmount, totalsales)
6 step solution
Problem 21
Use the following method headings to answer the questions below: public static int DetermineResult(int valuel, ref double value2) public static void DisplayResult(int valuel, double value2) public static int GetValue( ) a. How many parameters does each method have? b. What is the return type for each of the methods? c. If the methods belong to a class identified as GardenTool, write valid calls to each of the preceding methods. d. Which of the preceding methods will have a return statement as part of its body?
4 step solution
Problem 23
Write class methods to do the following: a. Display three full lines of asterisks on the screen. b. Accept as an argument your age, and display that value along with an appropriate label. c. Accept two floating-point values as arguments. Display the values formatted with three digits to the right of the decimal. d. Accept three int arguments and return their sum. e. Accept no arguments and return no values. Initialize a local Boolean variable to true. Have the method print the Boolean's value.
5 step solution
Problem 24
What will be produced from the following predefined Math class method calls? a. Console.WriteLine (Math.Abs (-98887.234) ); b. Console.WriteLine (Math.Pow \((4,3))\) c. Console.WriteLine (Math. \(\operatorname{sign}(-56)\) ) d. Console.WriteLine (Math. Sqrt ( 81) ) ; e. Console.WriteLine (Math.Min \((-56,56))\)
5 step solution