Wednesday, June 3, 2009

Methods

1. _________ methods can be called without the need for an object of the class to exist.
A) dependent
B) independent
C) special
D) static

Points Earned: 1.0/1.0
Correct Answer(s): D




2. Methods that call themselves are known as ________.
A) reiterative
B) repeat-calling
C) recursive
D) self-calling

Points Earned: 1.0/1.0
Correct Answer(s): C




3. Information may be ____ methods.
A) passed to
B) returned from
C) manipulated in
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




4. A method is invoked by a ____.
A) return statement
B) method header
C) method call
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




5. A return type of ____ is specified for a method that does not return a value.
A) nothing
B) null
C) void
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




6. Methods are called by writing the name of the method followed by ____ enclosed in parentheses.
A) a condition
B) arguments
C) a counter
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




7. Which of the following is not a way of packaging code?
A) namespaces
B) variables
C) methods
D) classes

Points Earned: 1.0/1.0
Correct Answer(s): B




8. Programmers write ____ to define specific tasks that may be used at many points in a program.
A) classes
B) methods
C) modules
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




9. Many prepackaged classes and methods are provided in the .NET FCL, an acronym for the .
A) Framework Class Library
B) Framework Class Listing
C) Form Class Library
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




10. Which of the following correctly calls the Math class method Sqrt with a value of 36?
A) Sqrt(36);
B) Math.Sqrt(36);
C) Math.Sqrt = 36;
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




11. Which of the following describes a static variable?
A) a variable with one copy shared by all class objects
B) a variable whose value may not be changed
C) all of the above
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




12. When may an application omit the string[] args parameter from the Main header?
A) when the application does not need to use strings
B) when the application does not take command-line arguments
C) when the application does not output any strings
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): B




13. Which of the following can be an argument to a method?
A) constants
B) variables
C) expressions
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




14. How are various parameters separated in the method header?
A) braces
B) brackets
C) periods
D) commas

Points Earned: 1.0/1.0
Correct Answer(s): D




15. Let there be method called Function which takes 3 parameters of type bool. Which of the following method headers could it represent?
A) Function(bool a, bool b, bool c)
B) Function()
C) Both of the above
D) None of the above

Points Earned: 1.0/1.0
Correct Answer(s): A




16. The parameter list in the method header and the arguments in the method call must agree in:
A) number
B) type
C) order
D) all of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




17. When an object is concatenated with a String:
A) a compilation error occurs
B) the object's class name is used
C) the object's ToString method is implicitly called
D) a runtime error occurs

Points Earned: 1.0/1.0
Correct Answer(s): C




18. To call a static method, use the _________ name followed by a period, and the method with its arguments.
A) class's
B) instance variable's
C) namespace's
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): A




19. Which keyword can programmers use to break out of a void method?
A) continue
B) next
C) break
D) return

Points Earned: 1.0/1.0
Correct Answer(s): D




20. A static method can ________.
A) call only other static methods of the same class directly
B) manipulate only static fields in the same class directly
C) be called using the class name and a dot (.)
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




21. Which statement is false?
A) Forgetting to return a value from a method that should return a value is a compilation error.
B) If a method does not return a value, the return-value-type in the method declaration can be omitted.
C) Placing a semicolon after the right parenthesis enclosing the parameter list of a method declaration is a syntax error.
D) Re-declaring a method parameter as a local variable in the method's body is a compilation error.

Points Earned: 1.0/1.0
Correct Answer(s): B




22. Stacks are _____________ data structures.
A) FIFO
B) Random
C) LIFO
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




23. What is pushed onto the program execution stack when a method is call?
A) the whole method
B) the return address of the method being called
C) the object of method being called
D) the class of the method being called

Points Earned: 1.0/1.0
Correct Answer(s): B




24. The local variables used in each invocation of a method during an application's execution are stored ________.
A) the program execution stack
B) the activation record
C) the stack frame
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




25. A(n) ____ conversion occurs when a type is converted to a type that can hold more data.
A) implicit
B) widening
C) explicit
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




26. An int must be explicitly casted to which of the following?
A) sbyte
B) double
C) bool
D) float

Points Earned: 1.0/1.0
Correct Answer(s): A




27. Let x be a double. How can you typecast a double into a float?
A) implicitly
B) x = float
C) (float)x
D) x(float)

Points Earned: 1.0/1.0
Correct Answer(s): C




28. What does the Framework Class Library hold?
A) namespaces
B) classes
C) methods
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




29. Which directive allows programmers to use the Framework Class Library?
A) namespace
B) using
C) load
D) import

Points Earned: 1.0/1.0
Correct Answer(s): B




30. A ____ is provided to a random number generator to ensure the same sequence of numbers is not generated during each execution.
A) date
B) parameter
C) seed
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




31. Random-number generator scaling is the process of:
A) causing each number in a range to have equal likelihood of being generated
B) modifying the range from which a number will be generated
C) calculating a sequence of numbers to be generated
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




32. A(n) ____ is a value type that contains a set of constant values.
A) enumeration
B) object
C) set
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




33. Which of the following cannot be an enum's underlying type?
A) int
B) ulong
C) sbyte
D) double

Points Earned: 1.0/1.0
Correct Answer(s): D




34. Identifiers declared within a class have ____.
A) block scope
B) class scope
C) local scope
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




35. If a local variable in a method has the same name as a variable in the main program, what will occur?
A) an error is generated
B) the variable in the main program is "hidden" until the method is finished executing
C) the variable in the main program will override the variable from the method
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




36. Which of the following statements describes block scope?
A) It begins at the opening { of the class declaration and terminates at the closing }
B) It is valid for one statement only.
C) It limits label scope to only the method in which it is declared.
D) It begins at the identifier's declaration and ends at the terminating right brace (}).

Points Earned: 1.0/1.0
Correct Answer(s): D




37. Which of these statements best defines scope?
A) Scoping allows the programmer to use a class without using its fully qualified name.
B) Scope is the portion of a program that can refer to an entity by its simple name.
C) Scope refers to the classes that have access to a variable.
D) Scope determines whether a variable's value can be altered.

Points Earned: 1.0/1.0
Correct Answer(s): B




38. Which of the following will violate the rules of overloading methods?
A) Methods with the same signatures but different return types.
B) Methods with different number of arguments.
C) Methods with different signatures but the same return type.
D) Method with different types of arguments.

Points Earned: 1.0/1.0
Correct Answer(s): A




39. Which of the following method header represents Function(true, 0, 2.6)?
A) void Function( bool b, double d, int c )
B) void Function( bool b, double d, double d )
C) void Function( bool b, int c, double d )
D) b and c

Points Earned: 1.0/1.0
Correct Answer(s): D




40. Overloaded methods always have the same _________.
A) return type
B) order of the parameter
C) number of the parameters
D) method name

Points Earned: 1.0/1.0
Correct Answer(s): D




41. The technique of dividing large programs into simple problems is known as divide and conquer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




42. C# provides features to facilitate the design, implementation, operation and maintenance of large programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




43. Methods can return at most one value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




44. The return type of a method's return value is specified in the method call.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




45. Modularizing a program with methods allows software reusability.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




46. Methods should be large and perform as many tasks as possible.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




47. Repeating high-quality, high-performance code in a program helps ensure higher quality programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




48. The statements defining a method are written every time they need to be executed.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




49. Prepackaged methods and classes are available for use in the .NET Framework Class Library.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




50. To provide a better understanding of a program, all methods and classes should be written by the programmer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




51. Methods defined by the programmer may only consist of predefined .NET method calls.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




52. Any variable declared with keyword const is a constant and cannot be changed after the constant is declared.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




53. A static variable represents class-wide information.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




54. A program contains a copy of a static variable for each object that is instantiated.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




55. The Math class only provides methods.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




56. Main is declared static because it is application's entry point; allows the execution environment to invoke Main without creating an instance of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




57. Methods are called by writing the name of the method followed by a left square bracket followed by the argument (or a comma-separated list of arguments) of the method followed by a right square bracket.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




58. Strings can only be concatenated with the function instance_variable.Concat("example").A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




59. When a method call is within another method call, the calls will execute from the outside in.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




60. Method arguments may not be expressions.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




61. A static method may access static and non-static members.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




62. To access the class's non-static members, a static method must use a reference to an object of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




63. When a return statement executes, control proceeds immediately to the first statement after the method that issues the return.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




64. Stack data structures have 3 functions.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




65. Since memory in a computer is finite, an error may occur known as stack overflow.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




66. Conversions that cause data loss are not allowed in C#.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




67. C# will attempt to perform conversions that do not result in data loss implicitly.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




68. Converting a simple type to another simple type may change the value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




69. By including using System; at the top of a C# source code, programmers can use the unqualified class name, Console, instead of the fully qualified class name, System.Console.A) True
B) False

Points Earned: 0.0/1.0
Correct Answer(s): True




70. Programmers must already know the namespaces he/she needs in order to use the Framework Class Library.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




71. It is always better to write your own code than to search and use a class from the FCL.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




72. Values returned by the Random class method Next are pseudo-random numbers.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




73. The Next method produces a random number from zero up to and including the number it is provided by the programmer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




74. A particular seed value always produces the same series of random numbers.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




75. When using Next, the range of possible values can be reduced, but the lowest value must be zero.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




76. The values produced by Random are weighted so that some values will be generated with greater frequency than others.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




77. Values produced by random-number generating methods are truly random. There is no way to predict the next result.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




78. If a change is made to an enumeration, the programmer must change the program in every place that the old value was used.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




79. To compare a simple-type value to the underlying value of an enumeration constant, you must use a cast operator to make the two types match.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




80. Any variables declared in a for structure header have block scope within that structure.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True

1 comment: