click below
click below
Normal Size Small Size show me how
Visual Basic 2019
Visual Basic 2019 Mind Trap Chapter 10 Classes and Objects
| Qusetion - Term | Answer - Definition |
|---|---|
| object-oriented programming language | which is a language that allows the programmer to use objects in an application’s interface and also in its code. A programming language that allows the programmer to use objects to accomplish a program’s goal. |
| OOP | object-oriented programming |
| Object | anything that can be seen, touched, or used -Boxes -List boxes -Buttons -Variables -Named Constants -Things found in real life like file on a disk. |
| Class | a pattern that the computer uses to create (instantiate) an object Every object in an object-oriented program is created from a. The class contains the instructions that tell the computer how the object should look and behave. Keep in mind that the class itself is not an object; only an instance of a class is an object. |
| Instance | an object created (instantiated) from a class A button control is an instance of the Button class. Keep in mind that the class itself is not an object; only an instance of a class is an object. |
| Instantiated | the process of creating an object from a class |
| Attributes | the characteristics that describe an object Attributes are also called properties. |
| Behaviors | an object’s methods and events |
| Methods | the actions that an object is capable of performing |
| Events | actions to which an object can respond; examples include clicking and double-clicking A click event is responding to a mouse click. |
| Encapsulates | an OOP term that means “contains” in a class To enclose in a capsule |
| A class is an object. True or False? | False |
| An object is an instance of a class. True or False? | True |
| An object’s attributes indicate the tasks that the object can perform. True or False? | False |
| What is a class? | A class is a pattern that the computer uses to create an object. |
| Class statement | a statement that invokes (calls) an independent Sub procedure or function. You define a class using the Class statement, which you enter in a class file. Syntax Public Class className attributes section behaviors section End Class |
| How to add a class file to an open Project? | 1. Click Project on the menu bar and then click Add Class. The Add New Item dialog box opens with Class selected in the middle column of the dialog box. 2. Type the name of the class, followed by a period and the letters vb, in the Name box. 3. Click the Add button. |
| What is the convention for naming a class | Pascal |
| Pascal Case | used when naming Sub procedures and functions; the practice of capitalizing the first letter in the name and the first letter of each subsequent word in the name TimeCard |
| How to instantiate an Object | {Dim | Private} variable As className variable = New className Private hoursInfo As TimeCard hoursInfo = New TimeCard The Private instruction creates a TimeCard variable named hoursInfo. The assignment statement then instantiates a TimeCard object and assigns it to the hoursInfo variable. or {Dim | Private} variable As New className Dim hoursInfo As New TimeCard |
| Write a statement that declares a procedure-level Employee variable named manager. | Dim manager As Employee |
| Write a statement that instantiates an Employee object and assigns it to the manager variable | manager = New Employee |
| Write a statement that declares a procedure-level Employee variable named hourly. The statement should also instantiate an Employee object, storing it in the hourly variable. | Dim hourly As New Employee |
| Member variables | the variables contained in a structure |
| Hidden | in OOP, this term refers to the fact that an object’s Private members are not visible to an application |
| Exposed | in OOP, this term refers to the fact that an object’s Public members are visible to an application |
| Public Property procedure | creates a Public property that an application can use to access a Private variable in a class |
| ReadOnly Keyword | used when defining a Property procedure; indicates that the property’s value can only be retrieved (read) by an application |
| WriteOnly Keyword | used when defining a Property procedure; indicates that an application can only set (write to) the property’s value |
| Get block | the section of a Property procedure that contains the Get statement |
| Set Block | the section of a Property procedure that contains the Set statement |
| Get statement | appears in a Get block in a Property procedure; contains the code that allows an application to retrieve the contents of the Private variable associated with the property |
| Set statement | appears in a Set block in a Property procedure; contains the code that allows an application to assign a value to the Private variable associated with the property; may also contain validation code |
| An application must use a Public member of a class to access the class’s Private members. True or False? | True |
| Which keyword indicates that a property’s value can be displayed but not changed by an application? | ReadOnly |
| In a Property procedure, validation code is typically entered in which statement: Get or Set? | Set |
| Contractor | a method whose instructions are automatically processed each time the class is used to instantiate an object; used to initialize the class’s Private variables; always a Sub procedure named New. Constructors never return a value, so they are always Sub procedures rather than functions. Syntax Public Sub New([parameterList]) instructions to initialize the class’s Private variables End Sub Notice that a constructor’s parameterList is optional |
| Default constructor | a constructor that has no parameters; a class can have only one default constructor A default constructor is allowed to initialize an object’s Private variables directly |
| parameterized constructor | a constructor that contains one or more parameters should use the class’s Public properties to access the Private variables indirectly. |
| signature | a method’s name combined with its optional parameterList. |