Deck 11: Classes and Objects

Full screen (f)
exit full mode
Question
In the following instruction,Room is a(n)____. Dim bedroom As New Room

A) object
B) variable
C) class
D) property
Use Space or
up arrow
down arrow
to flip the card.
Question
A one-dimensional array's Length property is an example of a ReadOnly property.
Question
A Public property procedure creates a property that is visible to any application that contains an instance of the class.
Question
Only an instance of a class-not the class itself-is an object.
Question
Private variables represent properties that will be seen by anyone using an object created from the class.
Question
A class is anything that can be seen,touched,or used;in other words,a class is nearly any thing.
Question
When naming the Private variables in a class,many programmers use the ____ as the first character and then use camel case for the remainder of the name.

A) dash
B) admiration sign
C) asterisk
D) underscore
Question
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
Question
The purpose of a(n)____ in OOP is to encapsulate the properties that describe an object,the methods that allow the object to perform tasks,and the events that allow the object to respond to actions.

A) event
B) class
C) method
D) attribute
Question
A class can have multiple default constructors.
Question
Constructors never return a value,so they are always Function procedures.
Question
____ are the actions to which an object can respond.

A) Attributes
B) Events
C) Behaviors
D) Methods
Question
____ are the operations (actions)that the object is capable of performing.

A) Events
B) Attributes
C) Behaviors
D) Methods
Question
You can overload any of the methods contained in a class.
Question
Which of the following instantiates a Product object and assigns it to the bookcase variable?

A) Dim bookcase As Product
B) Dim bookcase As New Product
C) Dim Product As bookcase
D) Dim bookcase As String
Question
When a variable in a class is declared using the Public keyword,it can be used only within the class.
Question
The Class statement ends with the keyword(s)____.

A) Class
B) Exit Class
C) End Class
D) Next Class
Question
Every object has ____,which are the characteristics that describe the object.

A) events
B) methods
C) attributes
D) behaviors
Question
A ____ encapsulates the attributes and behaviors of the object it creates.

A) constructor
B) property
C) class
D) structure
Question
In its simplest form,the Class statement can be used in place of the Structure statement.
Question
In a Property procedure,the dataType must match the data type of ____ associated with the Property procedure.

A) all constructors
B) all variables
C) the Public variable
D) the Private variable
Question
The first word in a method name should be a(n)____.

A) verb
B) noun
C) adjective
D) preposition
Question
Which of the following is a valid example of an object?

A) Place Order button in an application
B) credit card receipt
C) text box to enter the credit card number in an application
D) a and c
E) all of the above
Question
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
Question
A method name combined with its optional parameterList is called the method's ____.

A) signature
B) event
C) attribute
D) behavior
Question
Constructors that contain parameters are called ____.

A) attributes
B) default constructors
C) Set blocks
D) parameterized constructors
Question
A Property procedure begins with the keywords ____. A Property procedure begins with the keywords ____.  <div style=padding-top: 35px>
Question
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?

A) Private TaxRate As Double
B) Private _dblTaxRate As Double
C) Public TaxRate As Double
D) Public _dblTaxRate As Double
Question
When two or more methods have the same name but different parameters,the methods are referred to as ____.

A) default methods
B) parameterized methods
C) overloaded methods
D) Property procedures
Question
You create a Public property using a ____.

A) Sub procedure
B) Function procedure
C) Property procedure
D) Set block
Question
____ is useful when two or more methods require different parameters to perform essentially the same task.

A) Instantiation
B) Overloading
C) Encapsulation
D) Overriding
Question
You can create one class from another class.In OOP,this is referred to as ____.

A) encapsulation
B) overloading
C) overriding
D) inheritance
Question
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?

A) Inherit Truck
B) Inherits Truck
C) Inherit Automobile
D) Inherits Automobile
Question
The Tree class is derived from a base class named Plant.Which of the following statements can be used by the Tree class to invoke the Plant class's default constructor?

A) MyPlant.New()
B) MyBase.New()
C) MyTree.New()
D) MyTree.Base
Question
The Inherits clause is the keyword ____ followed by the name of the class whose attributes and behaviors you want the derived class to inherit.

A) It Inherits
B) InheritsFrom
C) Inherits
D) Inherits_From
Question
A(n)____ property gets its value from the class itself rather than from the application.

A) WriteOnly
B) ReadOnly
C) Set block
D) Get block
Question
If you create an auto-implemented property named State,Visual Basic will create a hidden Private variable named ____.

A) State
B) _State
C) STATE
D) state_
Question
A constructor that has no parameters is called the ____.

A) Property procedure
B) default constructor
C) parameterized constructor
D) Set block
Question
You indicate that a class is a derived class by including the ____ clause in the derived class's Class statement.

A) Inherits
B) Base
C) Overrides
D) Overloads
Question
The code in the ____ allows an application to assign a value to the Private variable associated with the property.

A) Get block
B) default constructor
C) Set block
D) Property procedure
Question
Rather than reuse the Shoe class,you have decided to derive the Boot class from the Shoe class.Which of the following creates the derived Boot class?

A) Private Class Shoe Inherits Boot
B) Private Class Boot Inherits Shoe
C) Public Class Shoe Inherits Boot
D) Public Class Boot Inherits Shoe
Question
What are classes and objects? How are they used in object-oriented programming?
Question
The Discount class is used by applications for assigning appropriate discounts to orders.A Public property within the class is made ReadOnly.Which of the following is true about this ReadOnly property?

A) The Set block of code will be entered in the class.
B) The applications using the Discount class will determine the appropriate discount.
C) The application will only be able to retrieve the discount.
D) The application will be able to change the discount.
Question
A base class named DeliveryFee contains a function named CalcFee that calculates an order's delivery fee using the following formula: total * .05.Write the method's procedure header in the base class that will allow the derived class to override the function.
Question
Write the appropriate block of code to complete a Public procedure based on the following statements:
Private _decTotalSales As Decimal
Write the appropriate block of code to complete a Public procedure based on the following statements: Private _decTotalSales As Decimal  <div style=padding-top: 35px>
Question
The Shoe class is used to create an object that represents a standard shoe.The Shoe class needs to be used in an application for boots.You have copied the Shoe.vb file into the boot application.What do you need to do next to include the file in the boot application?

A) Click PROJECT on the menu bar and then click Add Existing Item.
B) Select the Shoe.vb file from the list of filenames.
C) Click PROJECT on the menu bar and then click Add Class.
D) Click the Add button to add the file.
Question
Write the statements to create the default constructor for the Furniture class statement in the previous problem.Then write the Dim statement to use the default constructor to instantiate a Furniture object,assigning the object to a variable named sofa.
Question
Every object has attributes and behaviors.Describe each of these,including the two types of behaviors an object can have.
Question
The Lumber class definition contains two Private variables named _dblLength and _decPricePerFoot.The default constructor initializes the Private variables to 0 when the Lumber object is created.Write the statements to create a parameterized constructor,and then write the Dim statement using the parameterized constructor to instantiate and initialize the Lumber object where the number of feet of lumber is 31.5 and the price per foot is 1.85.
Question
Explain the difference between Public and Private variables for a class.
Question
Write a Class statement that defines a class named Employee.(The class contains four public variables named EmpID,LastName,FirstName,and PayRate.The EmpID,LastName,and FirstName variables are String variables.The PayRate variable is a Decimal variable. )Then write a statement that creates an Employee variable named partTime and also instantiates an Employee object,assigning it to the partTime variable.
Question
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.
Question
Write the code for an auto-implemented property named TaxableIncome.The property's data type is Decimal.Then list the two hidden items it creates.
Question
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.
Question
A base class named DeliveryFee contains a function named CalcFee that calculates an order's delivery fee using the following formula: total * .05.The derived class named InstallationFee contains the CalcFee method.However,the fee formula is as follows: (total * .05)+ 250.Write the function for the derived class.
Question
What is an auto-implemented property and what does it automatically create?
Question
What is a constructor? Explain the difference between a default constructor and a parameterized constructor.
Question
Define the term "inheritance" in object-oriented programming and describe its use.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/58
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 11: Classes and Objects
1
In the following instruction,Room is a(n)____. Dim bedroom As New Room

A) object
B) variable
C) class
D) property
C
2
A one-dimensional array's Length property is an example of a ReadOnly property.
True
3
A Public property procedure creates a property that is visible to any application that contains an instance of the class.
True
4
Only an instance of a class-not the class itself-is an object.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
5
Private variables represent properties that will be seen by anyone using an object created from the class.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
6
A class is anything that can be seen,touched,or used;in other words,a class is nearly any thing.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
7
When naming the Private variables in a class,many programmers use the ____ as the first character and then use camel case for the remainder of the name.

A) dash
B) admiration sign
C) asterisk
D) underscore
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
8
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
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
9
The purpose of a(n)____ in OOP is to encapsulate the properties that describe an object,the methods that allow the object to perform tasks,and the events that allow the object to respond to actions.

A) event
B) class
C) method
D) attribute
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
10
A class can have multiple default constructors.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
11
Constructors never return a value,so they are always Function procedures.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
12
____ are the actions to which an object can respond.

A) Attributes
B) Events
C) Behaviors
D) Methods
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
13
____ are the operations (actions)that the object is capable of performing.

A) Events
B) Attributes
C) Behaviors
D) Methods
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
14
You can overload any of the methods contained in a class.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following instantiates a Product object and assigns it to the bookcase variable?

A) Dim bookcase As Product
B) Dim bookcase As New Product
C) Dim Product As bookcase
D) Dim bookcase As String
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
16
When a variable in a class is declared using the Public keyword,it can be used only within the class.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
17
The Class statement ends with the keyword(s)____.

A) Class
B) Exit Class
C) End Class
D) Next Class
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
18
Every object has ____,which are the characteristics that describe the object.

A) events
B) methods
C) attributes
D) behaviors
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
19
A ____ encapsulates the attributes and behaviors of the object it creates.

A) constructor
B) property
C) class
D) structure
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
20
In its simplest form,the Class statement can be used in place of the Structure statement.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
21
In a Property procedure,the dataType must match the data type of ____ associated with the Property procedure.

A) all constructors
B) all variables
C) the Public variable
D) the Private variable
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
22
The first word in a method name should be a(n)____.

A) verb
B) noun
C) adjective
D) preposition
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is a valid example of an object?

A) Place Order button in an application
B) credit card receipt
C) text box to enter the credit card number in an application
D) a and c
E) all of the above
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
24
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
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
25
A method name combined with its optional parameterList is called the method's ____.

A) signature
B) event
C) attribute
D) behavior
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
26
Constructors that contain parameters are called ____.

A) attributes
B) default constructors
C) Set blocks
D) parameterized constructors
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
27
A Property procedure begins with the keywords ____. A Property procedure begins with the keywords ____.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
28
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?

A) Private TaxRate As Double
B) Private _dblTaxRate As Double
C) Public TaxRate As Double
D) Public _dblTaxRate As Double
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
29
When two or more methods have the same name but different parameters,the methods are referred to as ____.

A) default methods
B) parameterized methods
C) overloaded methods
D) Property procedures
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
30
You create a Public property using a ____.

A) Sub procedure
B) Function procedure
C) Property procedure
D) Set block
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
31
____ is useful when two or more methods require different parameters to perform essentially the same task.

A) Instantiation
B) Overloading
C) Encapsulation
D) Overriding
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
32
You can create one class from another class.In OOP,this is referred to as ____.

A) encapsulation
B) overloading
C) overriding
D) inheritance
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
33
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?

A) Inherit Truck
B) Inherits Truck
C) Inherit Automobile
D) Inherits Automobile
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
34
The Tree class is derived from a base class named Plant.Which of the following statements can be used by the Tree class to invoke the Plant class's default constructor?

A) MyPlant.New()
B) MyBase.New()
C) MyTree.New()
D) MyTree.Base
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
35
The Inherits clause is the keyword ____ followed by the name of the class whose attributes and behaviors you want the derived class to inherit.

A) It Inherits
B) InheritsFrom
C) Inherits
D) Inherits_From
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
36
A(n)____ property gets its value from the class itself rather than from the application.

A) WriteOnly
B) ReadOnly
C) Set block
D) Get block
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
37
If you create an auto-implemented property named State,Visual Basic will create a hidden Private variable named ____.

A) State
B) _State
C) STATE
D) state_
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
38
A constructor that has no parameters is called the ____.

A) Property procedure
B) default constructor
C) parameterized constructor
D) Set block
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
39
You indicate that a class is a derived class by including the ____ clause in the derived class's Class statement.

A) Inherits
B) Base
C) Overrides
D) Overloads
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
40
The code in the ____ allows an application to assign a value to the Private variable associated with the property.

A) Get block
B) default constructor
C) Set block
D) Property procedure
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
41
Rather than reuse the Shoe class,you have decided to derive the Boot class from the Shoe class.Which of the following creates the derived Boot class?

A) Private Class Shoe Inherits Boot
B) Private Class Boot Inherits Shoe
C) Public Class Shoe Inherits Boot
D) Public Class Boot Inherits Shoe
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
42
What are classes and objects? How are they used in object-oriented programming?
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
43
The Discount class is used by applications for assigning appropriate discounts to orders.A Public property within the class is made ReadOnly.Which of the following is true about this ReadOnly property?

A) The Set block of code will be entered in the class.
B) The applications using the Discount class will determine the appropriate discount.
C) The application will only be able to retrieve the discount.
D) The application will be able to change the discount.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
44
A base class named DeliveryFee contains a function named CalcFee that calculates an order's delivery fee using the following formula: total * .05.Write the method's procedure header in the base class that will allow the derived class to override the function.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
45
Write the appropriate block of code to complete a Public procedure based on the following statements:
Private _decTotalSales As Decimal
Write the appropriate block of code to complete a Public procedure based on the following statements: Private _decTotalSales As Decimal
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
46
The Shoe class is used to create an object that represents a standard shoe.The Shoe class needs to be used in an application for boots.You have copied the Shoe.vb file into the boot application.What do you need to do next to include the file in the boot application?

A) Click PROJECT on the menu bar and then click Add Existing Item.
B) Select the Shoe.vb file from the list of filenames.
C) Click PROJECT on the menu bar and then click Add Class.
D) Click the Add button to add the file.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
47
Write the statements to create the default constructor for the Furniture class statement in the previous problem.Then write the Dim statement to use the default constructor to instantiate a Furniture object,assigning the object to a variable named sofa.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
48
Every object has attributes and behaviors.Describe each of these,including the two types of behaviors an object can have.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
49
The Lumber class definition contains two Private variables named _dblLength and _decPricePerFoot.The default constructor initializes the Private variables to 0 when the Lumber object is created.Write the statements to create a parameterized constructor,and then write the Dim statement using the parameterized constructor to instantiate and initialize the Lumber object where the number of feet of lumber is 31.5 and the price per foot is 1.85.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
50
Explain the difference between Public and Private variables for a class.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
51
Write a Class statement that defines a class named Employee.(The class contains four public variables named EmpID,LastName,FirstName,and PayRate.The EmpID,LastName,and FirstName variables are String variables.The PayRate variable is a Decimal variable. )Then write a statement that creates an Employee variable named partTime and also instantiates an Employee object,assigning it to the partTime variable.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
52
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.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
53
Write the code for an auto-implemented property named TaxableIncome.The property's data type is Decimal.Then list the two hidden items it creates.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
54
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.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
55
A base class named DeliveryFee contains a function named CalcFee that calculates an order's delivery fee using the following formula: total * .05.The derived class named InstallationFee contains the CalcFee method.However,the fee formula is as follows: (total * .05)+ 250.Write the function for the derived class.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
56
What is an auto-implemented property and what does it automatically create?
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
57
What is a constructor? Explain the difference between a default constructor and a parameterized constructor.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
58
Define the term "inheritance" in object-oriented programming and describe its use.
Unlock Deck
Unlock for access to all 58 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 58 flashcards in this deck.