• Home
  • Textbooks
  • Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming
  • Advanced Method Concepts

Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming

Joyce Farrell

Chapter 8

Advanced Method Concepts - all with Video Answers

Educators


Chapter Questions

Problem 1

A mandatory parameter _______________
a. requires an argument to be sent from a method call
b. is any argument sent to a method
c. is preceded by the keyword man
d. All of the above are true.

Check back soon!

Problem 2

Which is not a type of method parameter in C\#?
a. value
c. reference
b. forensic
d. output

Check back soon!

Problem 3

Which type of method parameter receives the address of the variable passed in?
a. a value parameter
c. an output parameter
b. a reference parameter
d. two of the above

Check back soon!

Problem 4

When you declare a value parameter, you precede its name with _______________
a. nothing
c. the keyword val and a data type
b. a data type
d. the keyword ref and its data type

Check back soon!

Problem 5

Assume that you declare a variable as int $x=100$; and correctly pass it to a method with the declaration private static void IncreaseValue (ref int $x$ ). There is a single statement within the IncreaseValue() method: $x=x+25$;. Back in the Main() method, after the method call, what is the value of $x$ ?
a. 100
c. It is impossible to tell.
b. 125
d. The program will not run.

Check back soon!

Problem 6

Assume that you declare a variable as int $\mathrm{x}=100$; and correctly pass it to a method with the declaration private static void IncreaseValue (int $x$ ). There is a single statement within the IncreaseValue() method: $x=x+25$;. Back in the Main() method, after the method call, what is the value of $x$ ?
a. 100
c. It is impossible to tell.
b. 125
d. The program will not run.

Check back soon!

Problem 7

A reference parameter differs from an output parameter in that a reference parameter _______________ but an output parameter does not.
a. receives a memory address
b. occupies a unique memory address
c. requires an initial value
d. must be a simple data type

Check back soon!

Problem 8

A parameter array _______________
a. is declared using the keyword params
b. can accept any number of arguments of the same data type
c. Both of these are true.
d. Neither of these is true.

Check back soon!
02:19

Problem 9

Assume that you have declared a method with the following header: private static void DisplayScores(params int[] scores) Which of the following method calls is valid?
a. DisplayScores (20);
c. Disp1ayScores( $20,30,90)$;
b. DisplayScores $(20,33)$;
d. All of the above are valid.

Ernest Castorena
Ernest Castorena
Numerade Educator

Problem 10

Correctly overloaded methods must have the same _______________
a. return type
c. parameter list
b. identifier
d. All of the above.

Check back soon!
01:19

Problem 11

Methods are ambiguous when they _______________
a. are overloaded
b. are written in a confusing manner
c. are indistinguishable to the compiler
d. have the same parameter type as their return type

Manik Pulyani
Manik Pulyani
Numerade Educator

Problem 12

Which of the following pairs of method declarations represent correctly overloaded methods?
a. private static void MethodA(int a)
private static void MethodA(int b, double c)
b. private static void MethodB(double d)
private static void MethodB()
c. private static double MethodC(int e) private static double MethodD(int f)
d. Two of these are correctly overloaded methods.

Check back soon!

Problem 13

Which of the following pairs of method declarations represent correctly overloaded methods?
a. private static void Method(int a)
private static void Method(int b)
b. private static void Method(double d)
private static int Method()
c. private static double Method(int e)
private static int Method(int f)
d. Two of these are correctly overloaded methods.

Check back soon!
01:19

Problem 14

The process of determining which overloaded version of a method to execute is overload _______________
a. confusion
c. revolution
b. infusion
d. resolution

Manik Pulyani
Manik Pulyani
Numerade Educator

Problem 15

When one of a method's parameters is optional, it means that
a. no arguments are required in a call to the method
b. a default value will be assigned to the parameter if no argument is sent for it
c. a default value will override any argument value sent to it
d. you are not required to use the parameter within the method body

Check back soon!
02:10

Problem 16

Which of the following is an illegal method declaration?
a. private static void CreateStatement(int acctNum, double balance $=0.0$ )
b. private static void CreateStatement(int acctNum $=0$, double balance)
c. private static void CreateStatement(int acctNum $=0$, double balance $=0$ )
d. All of these are legal.

Manik Pulyani
Manik Pulyani
Numerade Educator
00:40

Problem 17

Assume you have declared a method as follows: private static double ComputeBill(int acct, double price, double discount $=0$ ) Which of the following is a legal method call?
a. ComputeBi110;
c. ComputeBi11(1001, 200.00$)$;
b. ComputeBi11(1001);
d. None of the above is legal.

Manik Pulyani
Manik Pulyani
Numerade Educator
00:40

Problem 18

Assume you have declared a method as follows: private static double CalculateDiscount(int acct $=0$, double price $=0$, double discount $=0$ ) Which of the following is a legal method call?
a. CalculateDiscount ();
b. CalculateDiscount $(200.00)$;
c. Ca1culateDiscount $(3000.00,0.02)$;
d. None of the above is legal.

Manik Pulyani
Manik Pulyani
Numerade Educator
02:03

Problem 19

Assume you have declared a method as follows: private static double DisplayData(string name $=$ "XX", double amount $=10.0$ )
Which of the following is an illegal method call?
a. DisplayData(name : "Albert");
b. DisplayData(amount : 200, name : "Albert");
c. DisplayData(amount : 900.00);
d. All of these are legal.

Willis James
Willis James
Numerade Educator

Problem 20

Suppose that you have declared an integer array named scores, and you make the following method call:
Tota1Scores(scores, num : 1);
Of the following overloaded method definitions, which would execute?
a. private static void TotalScores(int[] scores)
b. private static void Tota1Scores(int[] scores, int num)
c. private static void TotalScores(int[] scores, int num $=10$, int code $=10$ )
d. The program would not compile.

Check back soon!