Wednesday, June 3, 2009

Classes and Object

1. A constructor that has no arguments is called a ________.
A) parameterless constructor
B) main constructor
C) default constructor
D) zero-argument constructor

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




2. Instance variables or methods declared with the ____ modifier are accessible only in that class definition.
A) protected
B) static
C) private
D) None of the above.

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




3. A class's ____ initializes members of that class.
A) constructor
B) utility method
C) access modifier
D) None of the above.

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




4. The _________ of a class are also called the public services or the public interface of the class.
A) public constructors
B) public instance variables
C) public methods
D) All of the above

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




5. Indexers are defined with keyword ____.
A) this
B) index
C) indexer
D) None of the above.

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




6. Composition ____.
A) is a form of software reuse
B) is using an object reference as a class member
C) is a good design practice
D) All of the above.

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




7. Every class inherits directly or indirectly from class _________.
A) Super
B) object
C) Base
D) Inheritor

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




8. Which statement is false?
A) Clients generally care about what the class does but not how the class does it.
B) The actual data representation used within the class is of no concern to the class's clients.
C) Clients are usually involved in a class's implementation.
D) Hiding the implementation reduces the possibility that other program parts will become dependent on class-implementation details.

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




9. In a method in which a parameter has the same name as an instance variable, using the this reference allows you to refer to ________.
A) the parameter
B) the instance variable
C) varies depending on the situation
D) None of the above

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




10. Which of the following should usually be private?
A) methods
B) constructors
C) variables
D) All of the above

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




11. Which of the following statements is true?
A) Methods and instance variables can both be either public or private.
B) Information hiding is achieved by restricting access to class members via keyword public.
C) The public members of a class are not directly accessible to the client of a class.
D) None of the above is true.

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




12. Which of the following is a valid indexer header?
A) accessModifer returnType this [ IndexType1 name 1, …]
B) this [ IndexType1 name 1, …] accessModifer returnType
C) returnType accessModifer this [ IndexType1 name 1, …]
D) this [ IndexType1 name 1, …] returnType accessModifer

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




13. When should a program explicitly use the this reference?
A) when accessing a public variable
B) when accessing a field that is shadowed by a local variable
C) when accessing a private variable
D) when accessing a local variable

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




14. Object orientation uses classes to ____.
A) develop algorithms
B) encapsulate data and methods
C) organize large amounts of data
D) None of the above.

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




15. The use of references to objects of preexisting classes as members of new objects is called ____.
A) inheritance
B) composition
C) polymorphism
D) None of the above.

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




16. Constructors ____.
A) initialize instance variables
B) when overloaded, can have identical argument lists
C) when overloaded, are selected by number and types of parameters
D) A and C

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




17. A constructor cannot ____.
A) be overloaded.
B) initialize variables to their defaults
C) specify return types or return values
D) have the same name as the class

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




18. Having a this reference allows ____.
A) a method to refer explicitly to the instance variables and other methods of the object on which the method was called
B) a method to refer implicitly to the instance variables and other methods of the object on which the method was called
C) an object to reference itself
D) all of the above.

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




19. An object's this reference refers to:
A) the object itself
B) what the programmer specified
C) the entry point of the program
D) None of the above.

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




20. An instance of a user-defined type is called a(n) ____.
A) class
B) interface
C) object
D) None of the above.

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




21. Which of the following does not contribute to improved software reusability?
A) Licensing schemes and protection mechanisms.
B) Cataloging schemes and browsing mechanisms.
C) Descriptions of classes that allow programmers to determine whether a class fits their needs.
D) Quickly creating new class libraries without testing them thoroughly.

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




22. A common result of reusing software is ____.
A) virus infection
B) naming collisions
C) insecure programs
D) None of the above

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




23. Instance variables declared readonly do not or cannot ____.
A) be initialized
B) cause syntax errors if used as a left-hand value
C) use the principle of least privilege
D) be modified once the object is constructed

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




24. In C#, classes can only be declared with ___________ modifer(s).
A) public
B) private
C) internal
D) A and C

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




25. The term information hiding refers to:
A) public methods
B) accessing static class members
C) the process of releasing an object for garbage collection
D) hiding implementation details from clients of a class

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




26. Abstract Data Types ____.
A) elevate the importance of data
B) are only approximations or models of real-world concepts and behaviors
C) capture two notions, data representation and operations
D) All of the above

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




27. A class is made into a ____ for use in other programs.
A) dynamic link library
B) data location library
C) data loading library
D) None of the above.

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




28. How many parameters does the default constructor that C# creates for you have?
A) 3
B) 0
C) 1
D) varies

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




29. Failure to release resources when the program is no longer using them can cause ____.
A) buffer overflows
B) resource leaks
C) exceptions
D) None of the above.

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




30. Which statement is false?
A) A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public parameterless constructor.
B) Parameterless constructors do not have any arguments.
C) The compiler always creates a default constructor for a class.
D) If a class has constructors, but none of the public constructors are parameterless, and a program attempts to call a parameterless constructor to initialize an object of the class, a compilation error occurs.

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




31. 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




32. Stacks are commonly referred to as ____ data structures.
A) first-in, last-out
B) first-in, first-out
C) last-in, first-out
D) None of the above.

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




33. Which of the following is not true?
A) A static method can be accessed even when no objects of its class have been instantiated.
B) A static method or property must be used to access private static instance variables.
C) A static method can call instance methods directly.
D) A static method has no this reference.

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




34. Keyword ____ is used for constants whose values cannot be determined at compile time.
A) const
B) readonly
C) static
D) None of the above.

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




35. Composition is sometimes referred to as a(n) ________.
A) is-a relationship
B) have-a relationship
C) has-a relationship
D) one-to-many relationship

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




36. A ____ can be defined in a class to perform termination housekeeping on an object before the garbage collector reclaims the object's memory.
A) destructor
B) property
C) garbage collector
D) None of the above.

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




37. The affect of software reuse on the development of powerful, high-quality software is sometimes known as ____ (RAD).
A) rapid application design
B) rapid application development
C) reusable application design
D) reusable applications development

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




38. If no modifier is included in the class declaration, the class defaults to _______ access.
A) readonly
B) protected
C) private
D) public

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




39. C# programmers do not focus on ____.
A) carefully testing classes they design
B) crafting new classes and reusing existing classes
C) carefully documenting classes they design
D) understanding class library implementations

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




40. A ____ data structure can be described as a "waiting line."
A) stack
B) queue
C) list
D) None of the above.

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




41. Indexers are defined as properties in a class.A) True
B) False

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




42. this is often used to distinguish between a local variable and class variable that share an identical name.A) True
B) False

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




43. Variables or methods declared with access modifier public are accessible wherever the program has a reference to an object of the class.A) True
B) False

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




44. Indexers can be overloaded like methods.A) True
B) False

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




45. Member access modifiers are used to limit how much memory is available for class members.A) True
B) False

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




46. A constructor should return either true or false to determine if the object was initialized properly.A) True
B) False

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




47. The this reference may be used to increase program clarity, even if its use is optional.A) True
B) False

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




48. The data components of a class are called instance variables.A) True
B) False

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




49. The purpose of utility methods is to support the operation of a class' other methods.A) True
B) False

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




50. Instances of a class are called class variables.A) True
B) False

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




51. An attempt by a method which is not a member of a particular class to access a private member of that class is a fatal runtime error.A) True
B) False

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




52. An object of a class that has a reference to another object of the same class may access all the private data and methods of that class.A) True
B) False

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




53. The public methods of a class present the services that a class provides.A) True
B) False

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




54. The this reference can refer implicitly to the instance variables, properties and methods of an object.A) True
B) False

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




55. Programmers should not take into consideration that their code will be modified.A) True
B) False

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




56. Indexers are capable of returning any data type, even one that is different from the type of data in the list of elements.A) True
B) False

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




57. Only certain objects have the this reference.A) True
B) False

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




58. Variables declared within class methods are called instance variables.A) True
B) False

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




59. C# invokes the appropriate constructor by matching the number, types and order of the parameters in the constructor call to those in each constructor definition.A) True
B) False

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




60. Objects have the ability to hide their implementation from other objects.A) True
B) False

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




61. A constructor may not call other methods.A) True
B) False

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




62. 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




63. Only the first constructor for a class is defined without a return value. Subsequent constructors have the return type void.A) True
B) False

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




64. User-defined classes may be composed of other user-defined classes.A) True
B) False

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




65. Each object of a class has its own copy of all the instance variables of the class.A) True
B) False

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




66. The garbage collector looks for objects with no values.A) True
B) False

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




67. When overloading constructors, the order of arguments should be changed to prevent errors by the compiler.A) True
B) False

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




68. The compiler will create a default constructor for a class even if you already declared a constructor(s).A) True
B) False

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




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

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




70. Classes may be composed of only one other class.A) True
B) False

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




71. Attempting to overload a constructor with another constructor that has the exact same signature (name and parameters) is a compilation error.A) True
B) False

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




72. A destructor has the same name as the class and its constructor.A) True
B) False

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




73. Composition is a form of software reuse.A) True
B) False

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




74. A constructor may not have a return value.A) True
B) False

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




75. C# is like C++ in that programmers must manage memory explicitly.A) True
B) False

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




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

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




77. The programmer cannot determine when the garbage collector will execute.A) True
B) False

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




78. Variables that are static have class scope.A) True
B) False

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




79. Every class must have at east one constructor.A) True
B) False

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




80. A class cannot have references to objects of other classes as members.A) True
B) False

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

Inheritance

1. An advantage of inheritance is that:
A) all methods can be inherited
B) all instance variables can be uniformly accessed by base classes and derived classes
C) Objects of a derived class can be treated like objects of their base class
D) None of the above.

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




2. A derived class cannot access the ____ members of its base class.
A) private
B) static
C) protected
D) None of the above.

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




3. Which of the following pairs demonstrates the "is-a" relationship?
A) car, engine
B) book, table of contents
C) baseball, sport
D) None of the above

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




4. Which of the following is not a base/derived class relationship?
A) University/Boston University
B) Ford/Taurus
C) Sailboat/Tugboat
D) Country/USA

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




5. Which of the following statements is not true?
A) The class following the ":"in a class declaration is the direct base class of the class being declared.
B) A base class object is a derived class object.
C) C# does not support multiple inheritance.
D) A derived class is generally larger than its base class.

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




6. Identify which of the following examples could be considered a base class for the Computer class?
A) keyboard
B) hard-drive
C) machine
D) software

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




7. Which of the following pairs demonstrates the "has-a" relationship?
A) car, vehicle
B) house, window
C) teacher, person
D) None of the above

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




8. A method must be declared __________ for it to be overridden by derived classes.
A) overrides
B) overridable
C) virtual
D) None of the above

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




9. A class inherited from two or more levels up in the hierarchy is known as a ____.
A) indirect base class
B) direct base class
C) superclass
D) None of the above

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




10. Base class methods with this level of access cannot be called from derived classes.
A) protected
B) package
C) public
D) private

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




11. Inheritance is represented by a(n) ________ relationship.
A) "uses"
B) "is-a"
C) "has-a"
D) None of the above.

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




12. Which of the following classes is the root of the class hierarchy?
A) System.object
B) Point
C) ToString
D) None of the above

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




13. Which of the following is a potential problem associated with using protected instance variables with inheritance?
A) naming collisions occur more frequently
B) a derived-class method may assign illegal values
C) multiple copies of data may become inconsistent
D) None of the above

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




14. When a derived-class member overrides a base-class member, the base-class member can be accessed from the derived-class by using the keyword _____.
A) base
B) top
C) super
D) None of the above

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




15. private fields of a base class can be accessed in a derived class
A) by calling private methods declared in the base class
B) by calling public or protected methods declared in the base class
C) directly
D) All of the above

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




16. To avoid duplicating code (and possibly errors), use ________, rather than ________.
A) inheritance, the "copy-and-paste" approach.
B) the "copy-and-past" approach, inheritance.
C) a class that does not extend object, a class that explicitly extends object.
D) a class that explicitly extends object, a class that does not extend object.

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




17. How can a derived class call a base class constructor?
A) implicitly
B) explicitly
C) A and B
D) the derived class cannot call the base class constructor

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




18. Overriding a method differs from overloading a method because:
A) Overridden methods have the same signature.
B) For an overloaded constructor, the base class constructor will always be called first.
C) Overloaded methods have the same signature.
D) For an overridden constructor, the base class constructor will always be called first.

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




19. Which base class members are inherited by all derived classes of that base class?
A) protected instance variables and methods
B) private constructors
C) private instance variables and methods
D) protected constructors

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




20.
Which of the following statements are true?


A. We can use inheritance to customize existing software.
B. A base class specifies commonality.
C. A base class can be modified without modifying derived classes
D. A derived class can be modified without modifying its derived class.


A) All of the above
B) None of the above
C) A, B and C
D) A, B and D

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




21. The default implementation of method ToString of object returns a string representing ________.
A) the object's type
B) the object class name
C) namespace_name.object_class_name
D) None of the above

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




22. When a derived class constructor calls its base class constructor, what happens if the base class's constructor does not assign a value to an instance variable?
A) a compile-time error occurs
B) a run-time error occurs
C) a syntax error occurs
D) the program compiles and runs correctly because the instance variables are initialized to their default values

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




23. The default Equals implementation determines:
A) whether two references refer to the same object in memory.
B) whether two objects have the same instance variable values.
C) whether two objects have the same instance variables.
D) whether two references have the same type.

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




24. Every class in C#, except __________, extends an existing class.
A) String
B) Integer
C) Class
D) object

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




25. Which statement is true when a base class uses protected instance variables?
A) A derived class object can assign an invalid value to the base class's instance variables, thus leaving the object in an inconsistent state.
B) Derived class methods are more likely to be written so that they depend on the base class's data implementation.
C) We may need to modify all the derived classes of the base class if the base class implementation changes.
D) All of the above.

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




26.
Consider the classes below, declared in the same file:



class A
{
int a;
public A()
{
a = 7;
}
}

class B : A
{
int b;
public B()
{
b = 8;
}
}

Which of the statements below is not true?



A) After the constructor for class B is executed, the variable a will have the value 7.
B) A reference to class A can be treated as a reference to class B.
C) Both variables a and b are instance variables.
D) After the constructor for class B is executed, the variable b will have the value 8.

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




27. Which of the following is an example of a functionality that should not be "factored out" to a base class?
A) All animals lay eggs, except for mammals.
B) All vehicles know how to start and stop.
C) Both ducks and geese are birds that know how to start flying from the water.
D) All paints have a color.

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




28. A problem with inheritance is that a derived class can inherit members it does not need or should not have.A) True
B) False

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




29. All classes in C# have object as either a direct or indirect base class.A) True
B) False

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




30. A base class's constructors are inherited into its derived classes.A) True
B) False

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




31. A class that inherits from another class is referred to as the derived class.A) True
B) False

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




32. Members of a base class that are private are not inherited by derived classes.A) True
B) False

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




33. A derived class cannot change the implementation of its base class's methods.A) True
B) False

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




34. The process of abstraction allows programmers to focus on the commonalities among objects in the system.A) True
B) False

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




35. Derived classes provide the functionality and features inherited by base classes.A) True
B) False

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




36. Constructors are never inherited.A) True
B) False

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




37. A base class may have only one derived class.A) True
B) False

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




38. The protected members of a class may be accessed in their base class or any classes derived from that base class.A) True
B) False

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




39. A derived class can effect state changes in base class private members only through public, protected, internal methods provided in the base class and inherited into the derived class.A) True
B) False

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




40. An object of one class cannot be an object of another class.A) True
B) False

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




41. Every object of a base class is an object of that class's derived classes.A) True
B) False

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




42. Multiple inheritance, widely used in C#, is the process of inheriting from more than one class.A) True
B) False

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




43. Inheritance is the process of building a class with object references of other classes.A) True
B) False

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




44. A derived class is often larger and more general than its base class.A) True
B) False

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




45. The first task of any derived-class constructor is to call its base-class constructor.A) True
B) False

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




46. To enhance performance and reduce errors, it is a good idea to make derived classes larger than they need to be.A) True
B) False

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




47. Method Equals will accurately compare any two objects.A) True
B) False

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




48. The base reference may be "chained" to traverse further up in the class hierarchy.A) True
B) False

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




49. Using protected instance variables can cause derived-class methods to be written to depend on base-class implementation.A) True
B) False

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




50. When creating derived classes, programmers must use discretion in choosing the proper base class. Ideally, the base class will not contain superfluous capabilities or information.
A) True
B) False

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




51. A "copy-and-paste" approach is a simple and efficient way of providing functionality that exists in other classes.A) True
B) False

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




52. A key to improving the software development process is encouraging software reuse.A) True
B) False

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




53. When a program creates a derived-class object, the object constructor is the last constructor called and the first whose body finishes executing.
A) True
B) False

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




54. Inheritance preserves the integrity of a base class.A) True
B) False

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




55. If a base class constructor is overridden, the original constructor can no longer be called explicitly by the derived class.
A) True
B) False

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




56. Software that requires many modifications due to changing the name of one variable is considered fragile or brittle.A) True
B) False

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




57. A base class is designed by factoring out similarities among a set of classes.A) True
B) False

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




58. When a base class method is overridden in a derived class, it is common to have the derived class version call the base class version and do some additional work.
A) True
B) False

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




59. Every object in C# has at least seven methods: Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ReferenceEquals, and ToString.
A) True
B) False

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




60. There is no modifier that will allow both derived class members and assembly members access.A) True
B) False

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

Polymorphism

1. For which of the following would polymorphism not provide a clean solution?
A) A program to compute a 5% savings account interest for a variety of clients.
B) An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.
C) A billing program where there is a variety of clients who are billed with different fee structures.
D) A maintenance log program where a variety of machine data is collected and maintenance schedules are produced for each machine based on the data collected.

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




2. Assigning a derived class reference to a base class variable is safe ____
A) because the derived class has an object of its base class.
B) because the derived class is an object of its base class.
C) only when the base class is abstract.
D) only when the base class is concrete.

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




3. Polymorphism enables the programmer to:
A) hide information from the user.
B) absorb attributes and behavior from previous classes.
C) program in the specific.
D) program in the general.

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




4. Polymorphism involves:
A) the same message sent to a variety of objects
B) a specific message sent to each specific object
C) different messages sent to one object
D) None of the above.

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




5. Every object in C# knows its own class and can access this information through method ____.
A) ObjectClass()
B) GetInformation()
C) GetType()
D) ObjectInformation()

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




6. Abstract classes are classes which may not be:
A) inherited
B) accessed by derived-classes
C) instantiated
D) None of the above.

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




7. Which of the following is not true about interfaces?
A) An interface describes a set of methods that can be called on an object, providing a default implementation for the methods.
B) Interfaces are useful when attempting to assign common functionality to possibly unrelated classes.
C) An interface describes a set of methods that can be called on an object, without providing concrete implementation for the methods.
D) Once a class implements an interface, all objects of that class have an is-a relationship with the interface type.

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




8. Polymorphism specifically enables the creation of programs that handle:
A) classes that are containers for other classes
B) large amounts of data with efficiency
C) a wide variety of classes in a generic manner
D) None of the above

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




9. Polymorphism allows for specifics to be dealt with during:
A) execution
B) programming
C) debugging
D) compilation

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




10. Which of the following statements about abstract base classes is true?
A) abstract base classes must declare all data members not given values as abstract.
B) abstract base classes must declare all methods as abstract.
C) abstract base classes may not contain implementations of methods.
D) abstract base classes may contain data.

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




11. If an application needs to perform a derived-class-specific operation on a derived class object reference by a base class variable, the application must first cast the base class reference to a derived class reference through a technique known as _________.
A) upcasting
B) increasecasting
C) decreasecasting
D) downcasting

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




12. Classes which may be instantiated are ___________ classes.
A) instance
B) concrete
C) abstract
D) None of the above

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




13. If the base class contains only abstract method declarations, the baseclass is used for:
A) implementation inheritance.
B) interface inheritance.
C) Both.
D) Neither.

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




14. Consider this abstract class:



public abstract class Foo
{
private int a;
public int b;

public Foo( int aVal, int bVal )
{
a = aVal;
b = bVal;
} // end Foo constructor

public abstract int calculate();
} // end class Foo

Any concrete subclass that extends class Foo ____



A) Must implement a method called calculate.
B) Will not be able to access the instance variable a.
C) Will not be able to instantiate an object of class Foo.
D) All of the above.

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




15. When a base class variable refers to a derived class object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call?
A) execution time binding.
B) late binding.
C) execution binding.
D) just in time binding.

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




16. The convention of the UML is to denote the name of an abstract class in:
A) a diamond
B) there is no convention of the UML to denote abstract classes-they are listed just as any other class
C) bold
D) italics

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




17. Which declaration declares abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?
A) public int method1();
B) public int abstract method1();
C) public abstract int method1();
D) public int nonfinal method1();

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




18. Which statement best describes the relationship between base class and derived class types?
A) A derived class reference can be assigned to a base class variable and a base class reference can be assigned to a derived class variable.
B) A derived class reference can be assigned to a base class variable, but a base class reference cannot be assigned to a derived class variable.
C) A derived class reference cannot be assigned to a base class variable and a base class reference cannot be assigned to a derived class variable.
D) A base class reference can be assigned to a derived class variable, but a derived class reference cannot be assigned to a base class variable.

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




19. If a method needs to be called polymorphically, what type of reference should be used to point to the object that the method is being called with?
A) a reference of the abstract class that defines the behavior of the object
B) a reference of the same type as the object
C) an object reference to the actual object
D) None of the above.

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




20. Keyword _______ is used to indicate a method overloads a specific operator.
A) operator
B) implement
C) overload
D) op

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




21. Declaring a method sealed means:
A) it cannot be overloaded
B) it will prepare the object for garbage collection
C) it cannot be accessed from outside its class
D) it cannot be overridden

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




22. The UML distinguishes an interface from other classes by placing the word "interface" in above the interface name.
A) bold.
B) guillemets.
C) carets.
D) italics.

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




23. Which of the following does not complete the sentence correctly? An interface ____.
A) is used in place of an abstract class when there is no default implementation to inherit.
B) forces classes that implement it to declare all the interface methods.
C) cannot be instantiated.
D) can be instantiated.

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




24. Operator overloading is the process of:
A) enabling C#'s operators to work with class objects
B) using operators to create new classes
C) using operators to specify which versions of overloaded methods to use
D) None of the above.

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




25. A class that implements an interface but does not declare all of the interface's methods must be declared:
A) abstract
B) interface
C) public
D) final

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




26. The conventional name for an interface to be called Car is: ____
A) InterfaceCar
B) ICar
C) CarI
D) None of the above.

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




27. ________ code is the process by which the compiler replaces method calls with the code of a method to improve performance.
A) Debugging
B) Inlining
C) Compiling
D) None of the above.

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




28. The keyword sealed is applied to methods and classes to:
A) prevent overriding and inheritance
B) guarantee an implementation exists
C) specify a class is concrete
D) None of the above.

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




29. Interfaces can have ____ methods.
A) any number of
B) 0
C) 2
D) 1

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




30. A(n) ________ is best used for providing services that bring together disparate objects.
A) abstract class
B) concrete class
C) interface
D) None of the above.

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




31. The purpose of an interface is to: ____
A) provide similar objects with the same functionality, even though each will implement the functionality differently
B) provide different objects with the same functionality, even though each will implement the functionality differently
C) provide default implementations of methods and properties
D) None of the above.

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




32. All of the following methods are implicitly sealed except:
A) a private method.
B) a method in an abstract class.
C) a method declared in a sealed class.
D) static method.

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




33. Which of the following characteristics can be used to create an interface for a file, a cat and a house?
A) door
B) tail
C) age
D) None of the above.

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




34. Constants declared in an interface are implicitly _______.
A) private.
B) static.
C) abstract.
D) All of the above.

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




35. Overloaded operator methods must be declared public and ________.
A) sealed
B) protected
C) static
D) None of the above.

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




36. Classes and methods are declared sealed for all of the following reasons, except:
A) sealed methods are static.
B) sealed methods and classes prevent further inheritance.
C) sealed methods allow inlining the code.
D) sealed methods can improve performance.

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




37. Which is used to specify that a class will be implementing an interface?
A) extends.
B) using
C) :
D) implements

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




38. Polymorphism allows classes to be added with little or no modifications to the generic portion of a program.A) True
B) False

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




39. The abstract methods and properties do not provide an implementation.A) True
B) False

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




40. The programmer may define implementations for abstract methods to act as a default.A) True
B) False

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




41. The use of polymorphism helps promote software extensibility.A) True
B) False

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




42. An abstract base classes can be used to declare references.A) True
B) False

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




43. An abstract class may be derived from another abstract class.A) True
B) False

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




44. When a request is made to use a derived-class-object method through a base-class reference, C# polymorphically chooses the correct overridden method in the appropriate derived class that is associated with the object.A) True
B) False

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




45. If a derived class reference is assigned to a base class variable, the variable must be cast back to the derived class before any derived class methods can be called with it.A) True
B) False

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




46. The major drawback to polymorphically designed programs is that they do not take into account the future addition or deletion of classes.A) True
B) False

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




47. It is common object-oriented programming to define an iterator class that can walk through all the objects in a container (such as an array).A) True
B) False

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




48. When used correctly, polymorphism will never require changes to be made to any part of the program.A) True
B) False

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




49. The abstract keyword has the same effect as the virtual keyword.A) True
B) False

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




50. Casting base class references to derived class references is known as downcasting.A) True
B) False

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




51. Concrete classes provide implementations for every method and property they define.A) True
B) False

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




52. Polymorphism is particularly effective for implementing layered software systems.A) True
B) False

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




53. Polymorphism allows a programmer to command a wide variety of objects even if the programmer does not know the objects' types.A) True
B) False

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




54. Polymorphism enables objects of different classes that are related by a class hierarchy to be processed generically.A) True
B) False

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




55. Objects of abstract base classes can be instantiateD.A) True
B) False

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




56. All methods in an abstract class are inherently abstract.A) True
B) False

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




57. Polymorphism allows the addition of classes providing they were at least considered during program development.A) True
B) False

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




58. Unfortunately, polymorphic programs make it difficult to add new capabilities to a system.A) True
B) False

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




59. A class that implements an interface must define all methods and properties of that interface.A) True
B) False

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




60. An interface is typically used in place of an abstract class when there is no default implementation to inherit.A) True
B) False

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




61. An interface is used when there is a default implementation to inherit.A) True
B) False

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




62. Operators should be overloaded to perform similar actions they normally perform on objects of built-in types.A) True
B) False

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




63. All static and private methods are implicitly sealed.A) True
B) False

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




64. Abstract classes are used to provide data and services for objects.A) True
B) False

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




65. Sealing methods allows the compiler to optimize the program by "inlining code."A) True
B) False

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




66. All .NET languages support operator overloading.A) True
B) False

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




67. Excessive use of operator overloading can make a program difficult to read.A) True
B) False

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




68. An interface may not provide properties with get and set accessors.A) True
B) False

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




69. All methods in a sealed class must be explicitly declared sealed.A) True
B) False

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




70. An abstract class cannot have instance data and non-abstract methods.A) True
B) False

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




71. Methods that overload binary operators must take two arguments.A) True
B) False

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




72. Attempting to instantiate an object of an abstract class is a logic error.A) True
B) False

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




73. At least one argument of an operator overload method must be a reference to an object of the class in which the operator is overloaded.A) True
B) False

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




74. An interface reference may only invoke the methods that the interface declares.A) True
B) False

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




75. is returns true if two matching types are being compared.A) True
B) False

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




76. If a class leaves one method in an interface undeclared, the class is implicitly declared by C# as an abstract class.A) True
B) False

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




77. Interface methods may receive arguments.A) True
B) False

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




78. Declaring an interface protected allows for extra security precautions.A) True
B) False

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




79. An class that implements an interface may not act as a base class for other classes.A) True
B) False

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

Exception Handling

1. Intermixing program and error-handling logic:
A) increase a program's performance, because the program does not need to perform tests to determine whether the task executed correctly and the next task can be performed.
B) should be used in place of exception handling where possible.
C) can degrade a program's performance, because the program must perform (potentially frequent) tests to determine whether the task executed correctly and the next task can be performed.
D) None of the above.

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




2. Which of the following is not included in an exception's stack trace?
A) A descriptive message for the exception.
B) Instructions on handling the exception.
C) The method-call stack at the time the exception occurred.
D) The name of the exception.

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




3. Which of the following statements about try blocks is true?
A) The try block should contain statements that may throw an exception.
B) The try block must be followed by a finally block.
C) The try block should contain statements that may process an exception.
D) The try block must be followed by at least one catch block.

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




4. In C#, after an exception is handled, control resumes ____. This is known as the ____ model of exception handling.
A) just after the throw point, termination
B) after the last catch block, resumption
C) after the last catch block, termination
D) just after the throw point, resumption

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




5. Exceptions can occur:
A) from C#'s CLR
B) through explicitly mentioned code in a try block
C) through calls to other methods made in a try block
D) All of the above

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




6. What is the difference between a try block and a try statement?
A) There is no difference; the terms can be used interchangeably.
B) The try block refers to the keyword try followed by a block of code. The try block and its corresponding catch and/or finally clauses together form a try statement.
C) The try statement refers to the keyword try followed by a block of code. The try statement and its corresponding catch and/or finally clauses together form a try block.
D) A try statement refers to the block of code following the keyword try, while the try block refers to the try keyword and the block of code following this keyword.

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




7. In C#, try blocks are used for:
A) resolving exceptions.
B) testing code.
C) testing for infinite loops.
D) testing for exceptions.

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




8. Which of the following is not true regarding the throw point of an exception?
A) It specifies the point at which the exception must be handled.
B) It is the initial point at which the exception occurs.
C) It is specified as the top row of the method-call stack at the time the exception occurred.
D) All of the above statements are true.

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




9. If exception handling code is not nested, exceptions caught are in the _________.
A) finally block
B) throws block
C) try block
D) catch block

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




10. Which of the following statements is not true?
A) Exception handling can only catch the exception but cannot resolve the exception.
B) Exception handling enables programmers to write robust and fault-tolerant programs.
C) Exception handling can resolve exceptions.
D) There are many ways of handling exceptions.

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




11. Exception handling statements typically consist of:
A) if statements and throw blocks.
B) try blocks, catch blocks, and finally blocks.
C) try blocks, throw blocks, and finally blocks.
D) try blocks and catch blocks.

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




12. An exception is:
A) the way a computer signals to the users that it is about to terminate
B) something that the computer does not understand
C) a problem a computer has during construction
D) a problem that a program has during runtime

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




13.
In the catch block below, what is e?


catch ( DivideByZeroException e )
{
Console.WriteLine( e );
} // end catch


A) The type of the exception being caught
B) The name of catch block's exception parameter
C) An exception handler
D) A finally block

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




14. An uncaught exception:
A) is an exception that occurs for which there are no matching catch clauses.
B) is another term for a thrown exception.
C) is a possible exception that never actually occurs during the execution of the program.
D) is an exception that occurs for which the matching catch clause is empty.

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




15. Catch blocks that do not specify an exception type or an identifier ____________.
A) is an error
B) cannot catch any exceptions
C) can catch any exceptions
D) None of the above

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




16. With programming languages that do not support exception handling, which of the following happens?
A) programmers often delay writing error-processing code
B) programmers somethings forget to include error-processing code
C) programmers write less robust software products
D) All of the above

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




17. When an exception occurs it is said to have been:
A) declared
B) caught
C) handled
D) thrown

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




18. A FormatException is used to handle:
A) extra spaces input by the user
B) errors with deleting a file from disk
C) wrong data type inputs
D) all of the above

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




19. Re-throwing exceptions is used to:
A) catch even more errors in the program.
B) provide addition debugging information.
C) prevent the program from terminating from a fatal error.
D) All of the above

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




20. When an exception occurs, the try block _______.
A) expires
B) continues until a matching catch block
C) continues until the end of the try block
D) None of the above

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




21. User-defined exceptions should be derived from the:
A) ApplicationException class.
B) SystemException class.
C) Exception class.
D) ConsoleException class.

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




22. Which of the following statements is true?
A) The throw statement is used to throw an exception.
B) The throw statement is used to specify that a method will throw an exception.
C) The throw statement is used to access an exception parameter.
D) All of the above.

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




23. Which of the following statements is true?
A) The code in a finally block is executed only if an exception occurs.
B) The code in a finally block is executed only if an exception does not occur.
C) The code in a finally block is executed only if there are no catch blocks.
D) None of the above are true.

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




24. Which of the following statements is false?
A) The finally block and try block can appear in any order.
B) A finally block is optional.
C) A finally block should release all resources acquired in the corresponding try block.
D) A finally block is placed after the last catch block.

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




25. Which of the following is not a property of Exception?
A) Source
B) PrintError
C) HelpLink
D) TargetSite

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




26. The process that attempts to locate an appropriate catch handler for an uncaught exception is known as:
A) laddering
B) stack winding
C) stack unwinding
D) stack traversing

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




27. User-created exceptions can be created by:
A) overriding the Error class.
B) overriding the Exception property.
C) extending class Exception.
D) they cannot be created

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




28. The catch handler that catches an exception of type Exception should be
A) a catch handler that catches an exception of type Exception should not be used
B) last
C) anywhere
D) first

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




29. After a finally block has finished executing:
A) control returns to the throw point.
B) the application exits.
C) control proceeds to the first statement after the last catch block.
D) control proceeds to the first statement after the finally block.

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




30. Which of the following is true about the using statement?
A) It simplifies writing code in which you obtain a resource.
B) It only works with objects that implements from the IDisposable interface.
C) It implicitly places the code in a try block with a corresponding finally block that contains the object's Dispose method.
D) All of the above

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




31. According to Microsoft, programmer-defined exceptions should contain 3 constructors:
A) a default constructor, a constructor that receives a string for the error message and a constructor that receives an Exception argument of the inner exception object
B) a default constructor, a constructor that receives a string and a constructor that receives both a string and an exception
C) a constructor that receives a string, a constructor that receives an exception and a constructor that receives both
D) a default constructor, a constructor that receives a string and a constructor that receives a number indicating the line number where the exception occurred

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




32. If an exception is thrown in a catch handler, any code in the handler that follows the thrown exception will:
A) generate a logic error
B) generate a syntax error
C) never be executed
D) run after the finally block is done

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




33. In order to display the error message generated by an exception to the user, the programmer uses:
A) the Message property of class Exception
B) the ErrorMessage method of class Exception
C) the ErrorMessage property of class Exception
D) the Message method of class Exception

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




34. In order to tell the user what happened in an exception one must
A) pop the exception
B) toss the exception
C) throw the exception
D) access Exception properties

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




35.
Which of the following statements is true after a catch block is entered to handle an exception?


A. A catch block can rethrow an exception that it has not handled.
B. A catch block can rethrow an exception that it has partially handled.
C. A rethrown exception may be handled by an exception handler list after the enclosing try block.
D. A catch block cannot rethrow an exception that it has completely handled.


A) All of the above
B) B, C, D
C) A, B, C
D) A, B

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




36. The structure of exception handling varies from programmer to programmer.A) True
B) False

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




37. In many cases, handling an exception allows a program to automatically restart execution of the program from the beginning.A) True
B) False

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




38. Exception-handling reduces the likelihood that errors will be overlooked, thus making programs more robust.A) True
B) False

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




39. A NullReferenceException is thrown when there is an attempt to use a reference that points to nothing.A) True
B) False

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




40. Exception handlers typically access objects declared within their try blocks to determine the causes of the exceptions.A) True
B) False

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




41. If not done properly, exception handling can lead to resource leaks.A) True
B) False

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




42. Almost all runtime exceptions can usually be fixed by eliminating coding errors.A) True
B) False

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




43. Exceptions can only be handled one at a time.A) True
B) False

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




44. All exceptions cause the program to terminate when thrown.A) True
B) False

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




45. If an exception handler is to catch a variety of exceptions, use a comma-separated list of catch arguments in the catch handler.A) True
B) False

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




46. Exception handling was first implemented by Andrew Koenig and Bjarne Stroustrup.A) True
B) False

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




47. After an exception has occurred and a stack trace has been printed, the program may exit or continue executing, depending on the circumstances.A) True
B) False

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




48. A particularly severe problem could prevent a program from continuing normal execution, instead requiring the program to notify the user of the problem before terminating in a controlled mannerA) True
B) False

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




49. Variables local to try blocks are usable in the corresponding catch and finally blocks.A) True
B) False

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




50. The base class for all exception classes is System.Exception.A) True
B) False

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




51. C# throws an IntegerArithmeticException when division by zero in integer arithmetic occurs.A) True
B) False

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




52. There has to be a catch clause for every expected exception type.A) True
B) False

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




53. Exceptions are used by implementing class Exception.A) True
B) False

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




54. Using inheritance with exceptions enables an catch block to catch related exceptions using a concise notation.A) True
B) False

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




55. The Message property of an exception is what is displayed to the user should that exception be thrown.A) True
B) False

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




56. Read the .NET Framework classes' documentation for a detailed description of what Exceptions are thrown.A) True
B) False

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




57. The finally block is only executed if no error was reached in the try block.A) True
B) False

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




58. C# does not guarantee that a finally block (if one is present) will be executed if a try block is exited via a return, break or continue statement.A) True
B) False

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




59. If a finally block appears after the last catch block, it is executed only if an exception is thrown.A) True
B) False

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




60. The finally block is an ideal location for code that releases resources to prevent "resource leaks."A) True
B) False

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




61. As a rule of thumb all user-defined exceptions should end with Exception in their name.A) True
B) False

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




62. There can be no code in between try/catch/finally blocks.A) True
B) False

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




63. Each Exception should have three constructors: A default one, one that receives a string and one that receives a string and an exception.
A) True
B) False

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




64. The InnerException property is used to handle implemented exception cases.A) True
B) False

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




65. C#'s exception handling mechanism keeps error-processing code in the main line of a program's code to improve program clarity.A) True
B) False

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




66. Stack unwinding is the process that attempts to locate an appropriate catch handler for an uncaught exception.A) True
B) False

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




67. After the last catch block, the required finally block provides code that always executes regardless of whether or not an exception occurs.A) True
B) False

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




68. Resource de-allocation should be done explicitly in the finally block.A) True
B) False

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




69. The StackTrace property keeps track of all the method calls that occur in a program, and that is how a program knows which method caused the error.A) True
B) False

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




70. User defined exceptions are used to handle user defined objects.A) True
B) False

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




71. The constructor method for an exception class should be overloaded to allow the customizing of the display message.A) True
B) False

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

String

The bounds on a string are always:
A) 1 to string.Length.
B) 0 to string.Length - 1.
C) 0 to string.Length.
D) 1 to string.Length - 1.

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




2. If an IndexOfAny method is passed an array of characters it:
A) searches for the first occurrence of any of the characters in the string
B) generates an error
C) finds the first occurrence of each letter in the string
D) will search for the first occurrence of the sequence of characters

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




3. When comparing "a" to "_" the correct result would be:
A) "_" is greater
B) there is no way to compare "_" to "a"
C) "a" is greater
D) they are equal

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




4. If an IndexOfAny method is passed a string it:
A) generates an error
B) finds the first occurrence of each letter in the string
C) will search for the first occurrence of the sequence of characters
D) searches for the first occurrence of any of the characters in the string

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




5. Class String and the Char structure are found in the:
A) System.Chars Namespace
B) System namespace
C) System.Text namespace
D) System.Strings namespace

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




6. A string literal:
A) is a sequence of characters in double quotation marks.
B) contains numbers rather than letters.
C) contains only one character.
D) contains exactly its variable name and nothing else.

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




7. To create a string literal that excludes escape sequences, use:
A) @"string"
B) $"string"
C) !"string"
D) #"string"

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




8. When using the LastIndexOf method with three arguments, the second parameter specifies:
A) the length of the substring to search
B) the string to search for
C) the ending index of the string to search
D) the starting index of the string to search

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




9. If an integer argument goes beyond the bounds of the array then:
A) a RangeException is thrown
B) an ArgumentOutOfBoundsException is thrown
C) a BoundsException is thrown
D) an ArgumentOutOfRangeException is thrown

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




10. When creating a string object, if a character array is passed as well as two integers, then the created string equals:
A) there is no such constructor
B) the characters of the array from the first value for as many characters as the second value
C) all of the characters except those from the first value to the second value
D) the characters of the array from the first value to the second value

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




11. The string method CopyTo copies a specified number of characters from a:
A) char array into a string
B) string into a char array
C) string into a int array
D) All of the above

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




12. In the declaration: string color = "blue";
A) the string literal color is assigned to the string reference "blue"
B) the string reference color is assigned to the string literal "blue"
C) the string literal "blue" is assigned to the string reference color
D) None of the above

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




13. Concatenating with strings is done with:
A) method calls.
B) operator overloading.
C) operator overloading and method calls.
D) reserved words.

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




14. string indexers treat strings as:
A) a character
B) ASCII code
C) arrays of characters
D) binary code

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




15. The way to find out if two stings are equal is:
A) the Equals method
B) the CompareTo method
C) the == operator
D) All of the above

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




16. Which of the following cannot be used to form a word?
A) String
B) StringBuilder
C) Regex
D) An array of Chars
E) None of the above

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




17.
What does the following code print out?

string example = "C#_Programming";
Console.Write(example.Substring( 3, 5 );




A) _Pr
B) Pro
C) _Prog
D) Progr

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




18. When two integers are passed as arguments to the Substring method, it:
A) returns as many characters as the second integer starting at the first integer
B) generates an error
C) returns as many characters as the first integer starting at the second integer
D) returns the characters from the first integer to the second

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




19. The Equals string method is used to see if:
A) the ASCII sum of the characters in both strings are the same.
B) two strings are exactly the same.
C) the two strings have the same letter in the same position anywhere in the strings.
D) two strings start with the same letter.

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




20. To make a search return between 10 and 20 results use
A) { 10, 20 }
B) ( 10, 20 )
C) [ 10, 20 ]
D) < 10, 20 >

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




21. The IsPunctuation method returns True if the Char is ____.
A) a period (.) or a comma (,)
B) a period (.), a comma (,), a !, a ?, a colon (:), or a semicolon (;)
C) all of B, including all the braces ( (, {, and [ )
D) anything that is not a letter or a white space

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




22. If a Replace method is passed ( 'M', 'm', 0, 3 ) it will:
A) replace the first letter 'M' with 'm' in the first 4 characters
B) replace the first letter 'M' with 'm' in the first 3 characters
C) replace any letter 'M' with 'm' in the first 4 characters
D) replace any letter 'M' with 'm' in the first 3 characters

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




23. To make a quantifier lazy use:
A) a ? after it
B) a ? before it
C) a % before it
D) a % after it

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




24. ToUpper( string ) is
A) a way to make the first letter of every word in a string a capital letter.
B) a syntax error.
C) a way of converting a string to all upper cases.
D) a way of making one string more important than the rest.

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




25. If two StringBuilder objects contain the same string, then
A) they represent the same location in memory
B) they are two different objects
C) if one changes, so will the other
D) None of the above

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




26. When a quantifier is greedy it:
A) returns each result in alphabetical order
B) returns half the results
C) returns the longest result possible
D) returns a random number, more than one, of results

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




27. In order to set a string to reference nothing the programmer must use:
A) string1 = '\0'
B) string1 = ''
C) string1 = null
D) string1 = ""

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




28. Which is not a StringBuilder method?
A) Insert
B) Add
C) Replace
D) ReplaceAll
E) B and D

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




29. An example of a struct is:
A) an int
B) a double
C) a char
D) a byte
E) All of the above

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




30.
Use the snippet of code for the following question:

1. string example = "Deitel";
2. example = example + " Books";




A) This will not produce an error, and the string's value is "DeitelBooks".
B) This will not produce an error; however, line 2 will not change the string example.
C) This will produce an error
D) This will not produce an error, and the string's value is "Deitel Books".

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




31. The difference between {n} and {n,} is:
A) {n} matches exactly n occurrences
B) {n,} matches exactly n occurrences
C) {n,} generates a syntax error
D) {n} matches at least n occurrences

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




32. The proper way to convert a string to all lowercase is:
A) ToLower( string );
B) string.ToLower();
C) string.ToLower( string );
D) STRING = string;

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




33. The Split method is used to:
A) break a string into substrings, such that the substrings appear in the original string and are separated by at least one of the characters supplied
B) break a string into a character array
C) divide a string in half
D) break a string into individual characters

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




34. Class StringBuilder is used to:
A) create strings
B) manipulate strings
C) modify strings
D) All of the above

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




35. If a programmer desires to use an asterisk (*) literally in a regular expression, they use:
A) "\*"
B) "_*"
C) "/*"
D) "*"

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




36. If a number is formatted with the D3 formatter, it means that:
A) the number has to have at least 3 digits even if they are zero
B) the number has a dollar sign and is at least 3 digits long
C) creates each number in 3 dimensions
D) it is an error

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




37. Method AppendFormat allows:
A) anything added to a string.
B) numbers to be inserted in strings.
C) one string to be added to another.
D) some formatting to be made to the string.

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




38. string objects are ________ and StringBuilders are __________.
A) mutable, immutable
B) immutable, immutable
C) mutable, mutable
D) immutable, mutable

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




39. The StartsWith and EndsWith methods see if a string starts or ends with the given character or string.A) True
B) False

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




40. When a backslash is found within quotes it is considered part of an escape sequence.A) True
B) False

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




41. The Unicode character set has the same characters as ASCII.A) True
B) False

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




42. Method LastIndexOf is used to find the last occurrence of given text in a string.A) True
B) False

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




43. Both stings and characters should be enclosed in double quotes ("x").A) True
B) False

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




44. Method Replace can be used to change all occurrences of a desired character to another character.A) True
B) False

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




45. The concatenating of two strings is the merging of the two strings into another string.A) True
B) False

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




46. Strings are not able to be made from an array of characters.A) True
B) False

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




47. Another way to concatenate a string is to use the ampersand character (&).A) True
B) False

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




48. There are eight different String constructors.A) True
B) False

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




49. If a method's arguments cause it to access an index of the string that is beyond its length, the program will retrieve whatever is in that memory location.A) True
B) False

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




50. The Length property returns the length of a string.A) True
B) False

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




51. The Regex and Match classes are found in the System.Text namespace.A) True
B) False

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




52. Characters consist of the capital and lowercase alphabet.A) True
B) False

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




53. When using the string constructor (char, int), the character is repeated in a string as many times as specified by the integer.A) True
B) False

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




54. In order to concatenate a string with another string a programmer can use the Concat method.A) True
B) False

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




55. strings always know their size.A) True
B) False

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




56. When passed a white space, method Trim can be used to eliminate all characters from a string.A) True
B) False

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




57. The IndexOf method returns the indices of all occurrences of the given string.A) True
B) False

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




58. The letter 'Z' is greater than the letter 'b'.A) True
B) False

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




59. There are two substring methods that can return some of the characters of one string as an individual string.A) True
B) False

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




60. The ToUpper and ToLower methods can be used to convert a string to all upper or lower case letters, respectively.A) True
B) False

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




61. The CompareTo method returns a positive number if the invoking string is less than the argument, a negative number if the invoking string is greater and a 0 if they are the same.A) True
B) False

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




62. The LastIndexOfAny method scans through the array of characters backwards.A) True
B) False

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




63. A string is less than another string if it comes before it alphabetically.A) True
B) False

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




64. To obtain a single character from a string it can be treated as though it was an array.A) True
B) False

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




65. A string is a composition of characters used as one object.A) True
B) False

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




66. When a number is passed as an argument for a string indexer it returns that many characters starting from the first.A) True
B) False

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




67. Programmers can use classes Regex and Match to find patterns in a string.A) True
B) False

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




68. strings cannot be changed.A) True
B) False

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




69. The method IsWhiteSpace is only used to determine whether a character is a space or not.A) True
B) False

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




70. The ToString method is used to convert a StringBuilder into a string.A) True
B) False

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




71. When using the Replace method, the first character passed in is the letter to be replaced and the second is what it will be replaced by.A) True
B) False

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




72. Method Append is used to add the string representation of various data type values to the end of a StringBuilder.A) True
B) False

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




73. A lazy quantifier returns only the first case that matches the specifications.A) True
B) False

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




74. Replace is a method that allows the user to change any character in a StringBuilder to the given argument.A) True
B) False

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




75. Method Matches can be used to get a list of all matches with a character.A) True
B) False

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




76. Method Remove can be used to delete any part of a StringBuilder.A) True
B) False

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




77. Structs are like classes in that they encapsulate reference types.A) True
B) False

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




78. In regular expressions, a word character is considered to be any alphanumeric character.A) True
B) False

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




79. When setting the length of a StringBuilder to a length that is shorter than the current one, an ArgumentOutOfRangeException is thrown.A) True
B) False

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




80. Each StringBuilder has a limit of characters that cannot be exceeded.A) True
B) False

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




81. Method Match returns only a single match.A) True
B) False

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




82. Properties of controls need to be set at design time.A) True
B) False

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




83. Properties Length and Capacity are used to return the number of characters in the StringBuilder and the total length allowed (at that time) of the StringBuilder respectively.A) True
B) False

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




84. The char, int, and double types are all defined by structs.A) True
B) False

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




85. Method Insert can only be used on the primitive data types.A) True
B) False

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




86. When appropriate, using string objects instead of StringBuilder objects improves performance.A) True
B) False

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




87. The + character performs the same function as the asterisk *.A) True
B) False

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




88. Method AppendFormat can be used to format objects with spaces or using proper mathematical notations.A) True
B) False

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




89. When the Trim method is passed a character array it returns a string without any of the characters found within that array.A) True
B) False

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




90. Method EnsureCapacity is used to return the capacity of a StringBuilder.A) True
B) False

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




91. Method Insert can be used to insert various data types into a given position of a StringBuilder.A) True
B) False

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




92. By default all quantifiers are lazy.A) True
B) False

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




93. There are many character methods, some of which are capable of determining whether a character is a letter, a digit, a symbol, or a punctuation.A) True
B) False

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




94. Exceeding the capacity of a StringBuilder causes the program to throw an OutOfRangeException.A) True
B) False

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




95. Method Append can only be used on the primitive data types.A) True
B) False

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




96. The asterisk (*) can be used to match an expression zero or more times.A) True
B) False

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