Examlex

Solved

Problems - Correcting Logic and Code Errors

question 24

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


Definitions:

Sexually Transmitted Infections

Infections that are primarily spread through sexual contact; they can also be transferred by blood, needles, or from mother to child.

Common Bacterial STI

Refers to sexually transmitted infections caused by bacteria that are prevalent among sexually active individuals, such as chlamydia, gonorrhea, and syphilis.

Infectious Disease

Illnesses caused by pathogenic microorganisms, such as bacteria, viruses, fungi, or parasites, which can be transmitted, directly or indirectly, from one person to another.

Chlamydia

A common sexually transmitted infection (STI) caused by the bacterium Chlamydia trachomatis, which can affect both men and women.

Related Questions