Exam 11: Classes and Objects
An application has a Private variable named _ decGPA . Write the statements for the Property procedure named GPA to validate the value received from the application before assigning it to the Private variable.
Private _decGPA As Decimal
Public Property GPA As Decimal
Get
Return _decGPA
End Get
Set(value As Decimal)
If value > 0 Then
_decGPA = value
Else
_decGPA = 0
End If
End Set
End Property
What is an auto-implemented property and what does it automatically create?
An auto-implemented property enables you to specify the property of a class in one line of code. Visual Basic then automatically creates a hidden Private variable that it associates with the property. It also automatically creates hidden Get and Set blocks. The Private variable's name will be the same as the property's name, but it will be preceded by an underscore.
Write a Class statement that defines a class named Furniture. The class contains two private variables named _strItemNum and _dblPrice . Name the corresponding properties ItemNumber and Price.
Public Class Furniture
Private _strItemNum As String
Private _dblPrice As Double
Public Property ItemNumber As String
Get
Return _strItemNum
End Get
Set(value As String)
_strItemNum = value
End Set
End Property
Public Property Price As Double
Get
Return _dblPrice
End Get
Set(value As Double)
_dblPrice = value
End Set
End Property
End Class
A method name combined with its optional parameterList is called the method's ____.
A(n) ____ is a class method whose sole purpose is to initialize the class's Private variables.
Explain the difference between Public and Private variables for a class.
Case-Based Critical Thinking Questions Case 1 - chaussure.com
Chaussure.com is an online shoe retailer. The applications for the web site are developed using classes and object-oriented programming techniques.
An application needs to calculate the sales tax for an order. Which of the following is a valid example of a variable in a class that can be validated in the Set block of a Property procedure?
What are classes and objects? How are they used in object-oriented programming?
Which of the following clauses allows a derived class named Truck to have the same attributes and behaviors as its base class, which is named Automobile?
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.
____ are the operations (actions) that the object is capable of performing.
If you create an auto-implemented property named State, Visual Basic will create a hidden Private variable named ____.
The code in the ____ allows an application to assign a value to the Private variable associated with the property.
What is a constructor? Explain the difference between a default constructor and a parameterized constructor.
Private variables represent properties that will be seen by anyone using an object created from the class.
A ____ encapsulates the attributes and behaviors of the object it creates.
Constructors never return a value, so they are always Function procedures.
When a variable in a class is declared using the Public keyword, it can be used only within the class.
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)