Essay
Problems - Correcting Logic and Code Errors
The following sample of code contains errors. Rewrite the incorrect statements to correct all errors.
Public Class Truck
Private Property Miles As Decimal
Public Function New()
_Miles = 0
End Function
Public Sub New(ByVal decM As Decimal)
Miles = decM
End Sub
Public Overrider Function GetMPG() As Decimal
'returns the miles per gallon for a truck
Return _Miles / 30
End Function
End Class
'derived class
Public Class Car
Receives Truck
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal decM As Decimal)
MyBase.New(decM)
End Sub
Public Function GetMPG() As Decimal
Return _Miles / 18
End Function
End Class
Correct Answer:

Verified
Public Class Truck
Public Property Mile...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
Public Property Mile...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q4: You create a Public property using a
Q8: Write the statements to create the default
Q27: In a Property procedure,the dataType must match
Q30: Constructors never return a value,so they are
Q34: You can create one class from another
Q39: The purpose of a(n)_ in OOP is
Q46: When a variable in a class is
Q49: _ is useful when two or more
Q51: Every object has attributes and behaviors.Describe each
Q52: A Public property procedure creates a property