Chapter 9

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

17. When a value is assigned to a property, the property's ____________ is executed, and the value being assigned is contained in the value parameter. a. set accessor b. get accessor c. return statement d. ToValue method

ANS: A

2. You create a class by writing a(n) ____________. a. class declaration b. object specification c. preprocessor directive d. code blueprint

ANS: A

21. A constructor that accepts arguments is known as a(n) ____________. a. parameterized constructor b. alternate constructor c. constructor method d. aliased constructor

ANS: A

25. A method's ____________ is not part of the signature. a. return type b. name c. parameter data type d. argument kind

ANS: A

28. When you create an array of a class type, each element of the array is a ____________ variable. a. reference b. global c. numeric d. Boolean

ANS: A

36. When you add additional forms to a project, you add additional ____________, which are stored in their own source code files. a. classes b. objects c. methods d. events

ANS: A

38. To add a new form to a project, first click ____________ on the Visual Studio menu bar, and then select Add Windows Form... from the Project menu. a. Project b. File c. Tools d. Window

ANS: A

39. In Visual Studio, you can easily switch your view to another form by double-clicking the form's entry in the ____________ window. a. Solution Explorer b. Code c. Designer d. Data Sources

ANS: A

45. A ____________ allows the user to switch focus to another form while it is displayed. a. modeless form b. subsidiary form c. modal form d. minimized form

ANS: A

7. Classes are ____________ types. a. reference b. value c. abstract d. binary

ANS: A

11. When you call a method and pass a class instance as an argument, the parameter variable becomes a(n) ____________ to the object. a. copy b. reference c. address d. indicator

ANS: B

13. A special set of methods, known as ____________ work in conjunction with a private field. a. valuators b. accessors c. getters and setters d. transport methods

ANS: B

15. The ____________ is a method that returns the property's value. a. Me method b. get accessor c. Show method d. this.Value method

ANS: B

20. When a field's value is dependent on other data and the field is not updated when its related data changes, we say the field has become ____________. a. archaic b. stale c. obsolete d. frozen

ANS: B

26. A(n) ____________ is a class constructor that accepts no arguments. a. base constructor b. parameterless constructor c. overloaded constructor d. standard constructor

ANS: B

27. If you write a class with no constructor whatsoever, the compiler provides a(n) ____________. a. error message b. default constructor c. null reference variable d. void constructor

ANS: B

29. When you create an array of a class type, each element of the array will be initialized with the value ____________ by default. a. 0 b. null c. false d. void

ANS: B

3. The first line of a class declaration is known as the ____________. a. object heading b. class header c. data title d. class definition

ANS: B

30. To add an object of a class to a List, you use the ____________ method. a. Class b. Add c. Insert d. New

ANS: B

35. When you have identified the actions that a class is responsible for doing, you have identified its ____________. a. event handlers b. methods c. fields and/or properties d. actions

ANS: B

43. The ____________ displays a form on the screen, and it gives that form the focus. a. this.Focus method b. ShowDialog method c. Activate method d. NewForm method

ANS: B

44. When a ____________ is displayed, no other form in the application can receive the focus until the form is closed. a. static form b. modal form c. modeless form d. primary form

ANS: B

46. If you want to show a form in modeless fashion, call its ____________. a. this.Modeless method b. Show method c. ShowDialog method d. PopUp method

ANS: B

5. By using the ____________ access modifier, a class can hide its data from code outside the class. a. public b. private c. const d. ref

ANS: B

8. Which one of the following statements declares a variable named fox that references an instance of the Animal class? a. new Animal fox(); b. Animal fox = new Animal(); c. Animal fox; d. Animal new(fox);

ANS: B

1. Each object created from a class is called a(n) ____________ of the class. a. object b. reference c. instance d. field

ANS: C

12. A ____________ is a special type of class member that allows an object to store and retrieve a piece of data. a. variable b. field c. property d. method

ANS: C

14. The private field, which is known as the property's ____________, holds any data that is assigned to the property. a. hidden value b. shadow variable c. backing field d. data core

ANS: C

18. When you pass a property as an argument to a method, there is one restriction: Properties can only be passed ____________. a. by reference b. globally c. by value d. locally

ANS: C

19. A ____________ can be read, but it cannot be modified. a. private field b. public field c. read-only property d. hidden property

ANS: C

23. The process of matching a method call with the correct version of a method is known as ____________. a. pairing b. signing c. binding d. matching

ANS: C

31. The ____________ is the set of real-world objects, parties, and major events related to the problem. a. virtual world b. critical path c. problem domain d. project goal

ANS: C

34. When you have identified the information that a class is responsible for knowing, then you have identified the class's ____________. a. methods b. names c. fields and/or properties d. objects

ANS: C

37. When working with multiple forms, use the ____________ to change the name of the Form1.cs file to something more meaningful. a. Standard Toolbar b. Toolbox c. Solution Explorer d. Component Tray

ANS: C

40. If you wish to remove a form from a project and delete its file from the disk, first right-click on the form's entry in the Solution Explorer window, and on the pop-up menu, click ____________. a. Erase b. Remove c. Delete d. Purge

ANS: C

6. A(n) ____________ is a method that is automatically executed when an object is created. a. actuator b. loader c. constructor d. executable

ANS: C

9. Which one of the following statements calls the Jump method of the Animal class using a reference variable named fox? a. Animal.fox.Jump(); b. Animal(fox) = Jump(); c. fox.Jump(); d. fox = new Jump();

ANS: C

10. When adding a new class file to a Visual C# project, be sure that the filename ends with the ____________ extension. a. .cls b. .resx c. .src d. .cs

ANS: D

16. In a property definition, the ____________ is automatically created by the compiler, and its data type is the same as that of the property. a. this variable b. data parameter c. copy variable d. value parameter

ANS: D

22. When a method is ____________, it means that multiple methods in the same class have the same name but use different types of parameters. a. parameterized b. shadowed c. aliased d. overloaded

ANS: D

24. The compiler uses a method's ____________ to distinguish it from other methods of the same name. a. binding b. return type c. name d. signature

ANS: D

32. Each of the ____________ in the description of a problem domain is a potential class. a. verbs b. articles c. adjectives d. nouns

ANS: D

33. If you were developing an application for a local zoo, which one of the following nouns would not apply to the animal class? a. lions b. tigers c. bears d. zookeepers

ANS: D

4. A class's ____________ are statements that define the class's fields, properties, and methods. a. overall body b. field definitions c. private elements d. member declarations

ANS: D

41. If you wish to remove a form from a project but you do not want to delete its file from the disk, first right-click on the form's entry in the Solution Explorer window, and on the pop-up menu, click ____________. a. Hide Form Only b. Remove From Project c. Archive Form Data d. Exclude From Project

ANS: D

42. Suppose a project has a form named SummaryForm. Which one of the following statements creates an instance of the SummaryForm class and assigns it to a variable? a. SummaryForm.ShowDialog(); b. SummaryForm = this.Form(); c. mySummaryForm = SummaryForm(); d. mySummaryForm = new SummaryForm();

ANS: D

10. You should never declare a class in its own source file.

ANS: F

16. The set accessor is executed anytime that a property is read.

ANS: F

17. The get accessor has an implicit parameter called value.

ANS: F

21. To make a property read only, omit the get accessor for the property.

ANS: F

24. When designing a class, you should take care that all data is stored in a field, especially any calculated data.

ANS: F

25. Constructors cannot accept arguments in the same way as other methods.

ANS: F

27. Constructors cannot be overloaded, which means a class can have only one constructor.

ANS: F

29. Objects that are instances of a class cannot be stored in an array.

ANS: F

3. The class header defines a class's fields, properties, and methods.

ANS: F

32. All of the nouns that appear in the problem description should become classes.

ANS: F

4. When a class's fields are hidden from outside code, its data is vulnerable to accidental corruption.

ANS: F

40. Once a form has been created, it cannot be removed from a Visual Studio project.

ANS: F

42. Creating an instance of a form's class also displays the form on the screen.

ANS: F

43. A form can be both modal and modeless.

ANS: F

6. A class's constructor header must specify a return type of void.

ANS: F

7. A class's constructor must always use the private access modifier.

ANS: F

11. Because classes are reference types, objects that are instances of a class are always passed by reference.

ANS: T

12. Writing each class in its own separate file makes your code more organized and helps keep your source code files to a manageable size.

ANS: T

13. In code that creates an instance of a class, you access the class object's properties in the same way you would access public variables.

ANS: T

14. A property is a class member that behaves like a public field.

ANS: T

15. Some programmers begin the names of backing fields with an underscore to eliminate confusion between the field name and the property name.

ANS: T

18. When an accessor contains only a single return statement, many programmers prefer to write the entire accessor in one line of code.

ANS: T

19. Class fields are almost always declared private in order to protect them from accidental corruption.

ANS: T

2. The same rules for naming variables apply to naming classes.

ANS: T

20. If you try to pass a property to a ref or an out parameter, an error occurs.

ANS: T

22. To make a property read only, omit the set accessor for the property.

ANS: T

23. An error will occur if you to try to assign a value to a read-only property.

ANS: T

26. If two methods have the same names and parameter lists, you cannot overload them by just giving them different return types.

ANS: T

28. It is perfectly legal to write a class without any constructors.

ANS: T

30. When you want to create a List object, you follow List with the name of a class inside angled brackets, and it specifies that the List can hold only objects of that class type.

ANS: T

31. When designing an object-oriented application, one of your first tasks is to identify the classes that you will need to create.

ANS: T

33. When finding the classes in a problem description, sometimes a plural noun will indicate a class and a singular noun will indicate an object.

ANS: T

34. Once the classes have been identified in a problem description, the next task is to identify each class's responsibilities.

ANS: T

35. Designing an object-oriented application is an iterative process.

ANS: T

36. Every form in a Visual C# project is defined by a class.

ANS: T

37. When you have multiple forms in a project, you should give each form a meaningful name that describes its purpose.

ANS: T

38. Once you have added a form to a project, you can place any controls on it and write the necessary event handlers for the controls.

ANS: T

39. You can use the tabs appearing at the top of the Designer window to select different forms or their code to be displayed in the window.

ANS: T

41. In your application's code, the first step in displaying a form is to create an instance of the form's class.

ANS: T

5. The name of a class's constructor is the same as the name of the class.

ANS: T

8. When a class contains a method that uses the public access modifier, the method can be called from code outside the class.

ANS: T

9. When you create an object from a class, you use a reference variable to reference that object.

ANS: T

True or False 1. A class is not an object but a description of an object.

ANS: T


Set pelajaran terkait

Writing Workshop 1B: Types of Nouns

View Set

Chapter 24: Asepsis and Infection Control

View Set

Psychology: "Research Methods" by Michael W. Passer Glossary

View Set

7 - collaborators and resistance

View Set

HW 2 Construction Project Delivery System

View Set

Hormonal Control of Calcium Homeostasis

View Set