C# Exam
false
(T/F) A namespace is really nothing more than a group of statements placed together under a singlename.
false
(T/F) A standard convention used by programmers for naming classes is to use an action verb phrase.
True
(T/F) An appropriate identifier used to store the total transaction amount is totalTransactionAmount.
False
(T/F) An error will be produced when moreData is assigned the boolean variable shown above because the keyword true should be enclosed in double quotation marks.
False
(T/F) An int variable would be the most appropriate type for a memory location that will be used to store the monthly membership dues for the computer club.
true
(T/F) Both out and ref parameter types cause a method to refer to the same variable that was passed into the method.
True
(T/F) C# allows you to mix numeric integral types and floating-point types in an expression.
false
(T/F) Ceiling( ), Pow( ), and Floor( ) are all static members of the Console class.
False
(T/F) Classes and class diagrams are used most often with the structured procedural approach to software development.
False
(T/F) Comments are considered instructions to the computer.
True
(T/F) Each instruction statement has a semantic meaning—a specific way in which it should be used.
False
(T/F) In C#, it is tradition to name the file containing the class the same name as the class name, except the file name will have a .c# extension affixed to the end of the name.
false
(T/F) Methods may be defined in any order and placed anywhere in the file, in or outside of the class.
T
(T/F) One way to ensure that you have one entry and one exit from a method is to include a single return statement as the last statement in the method.
True
(T/F) Placing the two plus symbols (++) before an identifier causes one to be added to the memory location referenced by the variable prior to any other statement's execution.
True
(T/F) Procedural and object oriented are two commonly used design methods.
False
(T/F) Procedural programming is also called structured programming.
True
(T/F) Since C# is an object oriented language, everything is designed around a class.
True
(T/F) The Framework Class Library (FCL) consists of more than 2,000 classes.
true
(T/F) The Parse( ) method returns the number representation of its string argument.
true
(T/F) The Read( ) method is different from the ReadLine( ) method in that the Read( ) returns an int and the ReadLine( ) returns a string argument.
false
(T/F) The definition of the method includes the entry inside the curly braces, which is sometimes called the body of the method.
false
(T/F) The return keyword may not be included with a non-value returning method (void method).
True
(T/F) The rule that every statement should end with a semicolon is an example of a syntax rule.
True
(T/F) With only 8 bits, you can represent 2^8 or 256 different decimals.
False
(T/F) the value 78,888.90 is printed as output when the {0:c} format specifiers used in 78888.894
False
(T/f) The bool data type can take values of true/false and on/off/
True
(T/f) The result of "123" + "321" is "123321"
must be defined to have a void return type
A method that does not return any value on exit, ____.
Convert.ToDouble( )
A method used to convert from one base type to another is ____.
static
All Main( ) method headings must include the ____________ modifier meaning that the method belongs to the type itself rather than to a specific object of a class.
method
All programs consist of at least one ____________.
you can send in values through using the names of the parameters instead of having to worry about getting the exact order The Read( ) method ____. returns an int
An advantage of using named parameters is: ____.
ans = ans * v1--;
Another way to write the following expression is _______ ans *= v1 - 1
25
Avoid writing long methods. Consider refactoring when the method exceeds ____________ lines of code
value
Call by ____________ is the default parameter type.
static
Calls to ____ methods use the class identifier instead of the object identifier as the method qualifier.
value-returning
Calls to ____________ methods must be placed at a location in your code where the value could be accepted when the method is finished.
inline
Comments that use two forward slashes are called ____.
Ok\ "I'm sure"
Given the following output statement, what would be displayed? Console.Write("Ok\\ \"I\'m sure\"");
char letterGrade
If you expect to receive an "A" in this course, which of the following declarations would be most appropriate for storing the grade? A. char letterGrade; B. string grade; C. int letterGrade; D. double letterGrade;
logic
If you write a program and, instead of multiplying two values together as intended, you divide one value by the other, you produce a(n) ____ error.
Group functionally related types under a single name.
In a C# program, namespace is used to ____ a) display information on the monitor b) identify where the program begins c) add a reference to the most common classes in .NET d) group functionally related types under a single name
method's identifier followed by list of arguments
In order to call or invoke a nonvalue-returning method, enter the ____.
verb phrases
Method names should be defined with meaningful names using ____.
Console
One class predefined as part of .NET is ____ a) System b) Console c) namespace d) main
ReadKey( )
One option to holding the screen at the end of a program is to invoke Console.Read( ). Another option is to call ____________. It obtains the next character or function key from the user.
True
Problem specifications often include the desired output of the program in terms of what is to be displayed, saved, or printed.
System
The Math class has a number of static methods located in the ____ namespace.
returns an int
The Read( ) method ____.
ref
The ____ parameter type cannot be used unless the original argument is initialized before it is sent to the method.
Translating high-level programming language into machine-readable form
The compiler is responsible for ____. a) translating high-level programming language into machine-readable form b) controlling the operation of the system c) producing output from programming language such as C# d) producing UML diagrams during the design phase
False
The decimal equivalent for 3.42e-5 in scientific notation is .00342
includes the heading and the body
The definition of the method ____.
ref requires the original argument be initialized, out doesn't
The primary difference between call by reference using ref versus out is ____.
47.1
The result of the following expression is ______.double ans, v1 = 45.7, v2 = 10.5; int v3 = 5; ans = (int) v1 + v2 / (double) v3; A. 48.8 B. 47.1 C. 48 D. 47
True
The system namespace contains classes that define commonly used types or classes.
static methods
Unless a using statement is added to include the Math class, calls to members like Round( ), Max( ), and Exp( ), must be called using the class name, because they are all ____.
Class
Using the object-oriented approach, a(n) ____ is a combined set of attributes and actions.
29
What is stored in ans as a result of the arithmetic expression, given the following declarations? int ans = 5, v1 = 2, v2 = 10, v3 = 18; ans += v1 + 10 * (v2-- / 5) + v3 / v2; A. 27 B. 12 C. 29 D. none of the above
method
When naming a(n) ____________, use an action verb phrase.
optional parameter
When you assign a default value to a parameter, it then becomes a(n) ____.
All of the above
Which of the following formats displays two digits to the right of the decimal? A. {0:C} B. {0:c} C. {0:f2} D. all of the above
in
Which of the following is NOT a parameter type? a. out b. in c. ref d. params
Main( )
Which of the following is a user-defined method?
finaleGrade
Which of the following is a valid identifier? A. amount owed by student B. finaleGrade C. 4thExam D. score#1
ReadLine()
Which of the following methods are not overloaded?
amountOfRain
Which of the following would be the most appropriate identifier for a memory location that will store the amount of rainfall for a given period of time? a. time b. amount of rain c. amountOfRain d. amountofrainforsomeperiodoftime
Console.WriteLine("Good day!");
Which of the following would display "Good day!" on the screen? a) WriteLine.Console("Good day!"); b) Console.WriteLine["Good day!"]; c) WriteLine.Console{"Good day!"}; d) Console.WriteLine("Good day!");
WriteLine( ) advances to the next line after it finishes displaying output
WriteLine( ) differs from Write( ) in that ____. a) WriteLine( ) does not automatically advance to the next line b) smaller items are printed using Write( ) c) WriteLine( ) was added in later releases of C# d) WriteLine( ) advances to the next line after it finishes displaying output
arguments to the method
WriteLine("Final Grade = {0:N2}", CalculateGrade(90, 75, 83)); In the statement above, the values placed inside the parentheses following CalculateGrade are ____.
first argument should display two digits to the right of the decimal
WriteLine("Final Grade = {0:N2}", CalculateGrade(90, 75, 83)); The {0:N2} above indicates the ____.
Read( )
____ is added to hold the screen when the program runs.
Max( )
____________ is an overloaded method of the Math class that returns the larger of twospecified numbers.
void
____________ is used to indicate that no value is being returned from a method.
When naming local variable identifiers and parameters, use ____________.
camel casing
9
double answer = Math.Pow(3, 2); The result of the call to Math.Pow( ) in the above statement is to store ____ in answer:
answer = Math.Abs(-23)
public static int Abs(int) Which of the following would be a valid call to the above method?
public
public static void Main( )The access modifier in the heading above is the keyword ____.
void
public static void Main( )The return type for the method above is ____.