Exam 11: Classes and Objects

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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.

Free
(Essay)
4.9/5
(39)
Correct Answer:
Verified

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?

Free
(Essay)
4.7/5
(31)
Correct Answer:
Verified

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.

Free
(Essay)
5.0/5
(29)
Correct Answer:
Verified

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

(Multiple Choice)
4.9/5
(28)

A(n) ____ is a class method whose sole purpose is to initialize the class's Private variables.

(Multiple Choice)
4.8/5
(39)

Explain the difference between Public and Private variables for a class.

(Essay)
4.8/5
(32)

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?

(Multiple Choice)
4.8/5
(40)

What are classes and objects? How are they used in object-oriented programming?

(Essay)
4.8/5
(32)

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?

(Multiple Choice)
4.9/5
(43)

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.

(Multiple Choice)
4.7/5
(31)

____ are the operations (actions) that the object is capable of performing.

(Multiple Choice)
4.9/5
(36)

If you create an auto-implemented property named State, Visual Basic will create a hidden Private variable named ____.

(Multiple Choice)
4.8/5
(32)

The code in the ____ allows an application to assign a value to the Private variable associated with the property.

(Multiple Choice)
4.9/5
(31)

What is a constructor? Explain the difference between a default constructor and a parameterized constructor.

(Essay)
4.8/5
(34)

____ are the actions to which an object can respond.

(Multiple Choice)
4.9/5
(37)

A class can have multiple default constructors.

(True/False)
4.7/5
(34)

Private variables represent properties that will be seen by anyone using an object created from the class.

(True/False)
4.8/5
(35)

A ____ encapsulates the attributes and behaviors of the object it creates.

(Multiple Choice)
4.9/5
(38)

Constructors never return a value, so they are always Function procedures.

(True/False)
4.7/5
(32)

When a variable in a class is declared using the Public keyword, it can be used only within the class.

(True/False)
4.8/5
(38)
Showing 1 - 20 of 60
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)