Question: Write a Class statement that defines a class named Book. The class contains three Public variables: Title, Author, and Price. The Title and Author variables
Write a Class statement that defines a class named Book. The class contains three Public variables: Title, Author, and Price. The Title and Author variables are String variables. The Price variable is a Decimal variable. Then use the syntax shown in Version 1 in Figure 11-5 to declare a variable that can store a Book object; name the variable fiction. Also write a statement that instantiates the Book object and assigns it to the fiction variable.

Instantiating an Object from a Class Syntax Version 1 (Dim | Private) variableName As className variableName = New className Syntax Version 2 (Dim | Private) variableName As New className Example 1 (using Syntax Version 1) Private hoursInfo As TimeCard O = hoursInfo = New TimeCard The Private instruction creates a TimeCard variable named hoursInfo; the assignment statement instantiates a TimeCard object and assigns it to the hoursInfo variable. Example 2 (using Syntax Version 2) Dim hoursInfo As New TimeCard The Dim instruction creates a TimeCard variable named hoursInfo and also instantiates a TimeCard object, which it assigns to the hoursInfo variable.
Step by Step Solution
3.40 Rating (162 Votes )
There are 3 Steps involved in it
Public Class Book Public Ti... View full answer
Get step-by-step solutions from verified subject matter experts
