CSS 331 - Exam II Review: Chapter 10
True
(T/F) A Private variable in a class can be access directly by a Public method in the same class. a. True b. False
False
(T/F) A ReadOnly property can be an auto-implemented property. a. True b. False
True
(T/F) A WriteOnly property can be an auto-implemented property. a. True b. False
True
(T/F) One of the disadvantage of using Public variables in a class is that a class cannot control the values assigned to its Public variables. a. True b. False
True
(T/F) Private variable in a class can be accessed directly by a Public method in the same class. a. True b. False
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
Public property procedure
creates a Public property that an application can use to access a Private variable in a class
Class statement
the statement used to define a class in Visual Basic
Member variables
the variables declared in the attributes section of a class
Overloaded methods
two or more class methods that have the same name but different parameterLists
WriteOnly keyword
used when defining a Property procedure; indicates that an application can only set (write to) the property's value
ReadOnly keyword
used when defining a Property procedure; indicates that the property's value can only be retrieved (read) by an application
Instantiated
the process of creating an object from a class
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
Class
A ________ can have only one default constructor.
ParameterList
A class can have as many parameterized constructor as needed, but each ________________ lmust be unique.
State = strName
A class contains a Private variable named strState. The variable is associated with a Public property name State. Which of the following is the best way for a parameterized constructor to assign the value stored in its strName parameter to the variable? a. strState = strName b. State = strState c. strState = State.strName d. State = strName
_Title = "Unknown"
A class contains an auto-implemented property name Title. Which of the following is the correct way for the default constructor to assign the string "Unknown" to the variable associated with the property? a. _Title = "Unknown" b. _Title.strTitle = "Unknown" c. Title = "Unknown" d. None of the Above
a Sub procedure
A constructor is _____________. a. a function b. a Property procedure c. a Sub procedure d. either a function or a Sub procedure
Default parameter
A constructor that has no parameters is called _______________.
Parameterized
A constructor that has one or more parameters is called a ______________ constructor.
constructor
A(n) ____ is a class method whose sole purpose is to initialize the class's Private variables. a. signature b. constructor c. Get block d. event
Sub, New
All constructors are _____ procedures that are named ________.
parameterized constructors
Constructors that contain parameters are called _______. a. attributes b. default constructors c. Set blocks d. parameterized constructors
Private
To hide one of a class's member, you declare the member using which of the following keywords? a. Hide b. Invisible c. Private d. ReadOnly
using properties created by Public Property procedures
How can an application access the Private variables in a class? a. directly b. using properties created by Public Property procedures c. Through Private procedures contained in the class d. None of the Above
Set
If you need to validate a value before assigning it to a Private variable, you enter the validation code in which block in a Property procedure? a. Assign b. Get c. Set d. Validate
Get
In a Property procedure, the code contained in the ________ block allows an application to retrieve the contents of the Private variable associated with the property. a. Set b. Assign c. New d. Get
New
Which of the following is the name of the Inventory class's default constructor? a. Inventory b. InventoryConstructor c. Default d. New
Behaviors
an object's methods and events
onHand.ItemId = "XG45"
The Inventory class contains a Private variable named strId. The variable is associated with the Public ItemId property. An application instantiates an Inventory object and assigns it to a variable named onHand. Which of the following can be used by the application to assign the string "XG45" to the strId variable? a. onHand.ItemId = "XG45" b. ItemId.strId = "XG45" c. onHand.strId = "XG45" d. ItemId.strId = "XG45"
dblDiscount = cellPhone.GetDiscount
The Item class contains a Public method named GetDiscount. The method is a function. An application instantiates an Item object and assigns it to a variable named cellPhone. Which of the following can be used by the application to invoke the GetDiscount method? a. dblDiscount = Item.GetDiscount b. dblDiscount = cellPhone.GetDiscount c. dblDiscount = GetDiscount.cellPhone d. cellPhone.GetDiscount
intNewPrice = Price.GetNewPrice
The Product class contains a Private variable named _intPrice. The variable is associated with the Public Price property. An application instantiates a Product object and assigns it to a variable named item. The Product class above contains a Public method named GetNewPrice. The method is a Function procedure. Which of the following can be used by the application above to invoke the GetNewPrice method? a. intNewPrice = Call GetNewPrice b. intNewPrice = Price.GetNewPrice c. intNewPrice = item.GetNewPrice d. intNewPrice = item.GetNewPrice(item._intPrice)
lblTax.Text = currentSale.Tax.ToString("C2")
The Purchase class contains a Read Only property named Tax. The property is associated with the Private dblTax variable. A button's Click even procedure instantiates a Purchase object and assigns it to the currentSale variable. Which of the following is valid in the Click procedure? a. lblTax.Text = currentSale.Tax.ToString("C2") b. currentSale.Tax = 15 c. currentSale.Tax = dblPrice * 0.05 d. None of the Above
Get
The Return statement is entered in which statement in a Property procedure? a. Get b. Set
Object
anything that can be seen, touched, or used
constructor
The instructions of a ________ are automatically processed each time an object is instantiated from the class. a. structure b. designer c. loader d. constructor
signature
The method name combined with the method's optional parameterList is called the method's _____________. a. autograph b. inscription c. signature d. statement
.vb
The name of a class file ends with which of the following filename extensions? a. .cla b. .cls c. .vb d. None of the Above
auto-implemented
To specify the property of a class in one line, create an ____________________ property using syntax shown in Figure 10-27 in the textbook.
overloaded
Two or more methods that have the same name but different parameterLists are referred to as what type of methods? a. loaded b. overloaded c. parallel d. signature
Dim chair As New Inventory
Which of the following instantiates an Inventory object and assigns it to the 'chair' variable? a. Dim chair As Inventory b. Dim chair As New Inventory c. Dim chair = New Inventory d. Dim New chair As Inventory
Events
the actions to which an object can respond
ReadOnly
To create a property whose value an application can only retrieve, include the ____________ keyword in the Property procedure's header.
WriteOnly
To create a property whose value an application can only set, include the ___________ keyword in the Property procedure's header.
Giving them the same name but different parameterLists
To create two or more methods that perform the same task but require different parameters, overload the methods by ____________________________.
Public
To expose a variable or method contained in a class, you declare the variable or method using the keyword ___________. a. Exposed b. Private c. Public d. Viewable
Attributes
the characteristics that describe an object
None of the Above
Which of the following is the name of the Animal class's default constructor? a. Animal b. AnimalConstructor c. Default d. None of the Above
A class can contain only one constructor
Which of the following statements is False? a. A class can contain only one constructor b. An example of a behavior is the SetTime method in a Time class c. An object created from a class is referred to as an instance of the class d. An instance of a class is considered an object
inheritance
You can create one class from another class. In OOP, this is referred to as ________. a. encapsulation b. overloading c. overriding d. inheritance
Parameterized constructor
a constructor that contains one or more parameters
Default constructor
a constructor that has no parameters; a class can only have one default constructor
Constructor
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
Signature
a method's name combined with its optional parameterList
Class
a pattern that the computer follows when instantiating (creating) an object
Object-Oriented Programming language
a programming language that allows the use of objects in an application's interface and code
Encapsulates
an OOP term that means "contains" in a class
Instance
an object created from a class
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
Auto-Implemented properties
the Visual Basic feature that enables you to specify the property of a class in one line
OOP
the acronym for object-oriented programming
Methods
the actions that an object is capable of performing