I would appreciate help on the following assignment. This is one assigment: I ha
ID: 3628137 • Letter: I
Question
I would appreciate help on the following assignment. This is one assigment:I have to "identify the output of the code that uses the following two classes:
-Dim cb As Cube = New Cube()
txtOutput.Text = CStr(cb.Result(2))
-Dim m As Square = New Cube()
txtOutput.Text = CStr(m.Result(2))
-Consider the class hierarchy in the second practice problem. What value is assigned to the variable phrase by the following two lines of code?
"Dim vertebrate As New Anthropods()
Dim phrase As String = anthropod.Msg"
thakn you!
Explanation / Answer
Dim cb As Cube = New Cube() ' txtOutput.Text = CStr(sq.Result(2)) Answer: Error if sq.Result(2) is take as object sq has not been defined If we consider it as cb.Result(2), the output would be 8 '4. Dim m As Square = New Cube() ' txtOutput.Text = CStr(m.Result(2)) ' Answer: 8 Consider the class hierarchy in the second practice problem. What value is assigned to the variable phrase by the following two lines of code? ' '6. Dim vertebrate As New Vertebrates() ' Dim phrase As String = vertebrates.Msg ' Answer: Cannot be determined as there is no class Vertebrates given anywhere In exercise 7 through 16, identify the errors in the code. ' '8. Class Hello ' Function Hi() As String ' Return "hi!" ' End Function ' End Class ' ' Class Greetings ' Inherits Hi() //Error in this line: can not inherit function, should inherit class ' Function GoodBye() As String ' Return "goodbye" ' End Function ' End Class ' '10. Class Hello ' Function Hi() As String //must be declared overridable as child class is overriding it ' Return "hi!" ' End Function ' End Class ' ' Class WithIt ' Inherits Hello ' Overrides Function Hi() As String ' Retrun "Hey" ' End Function ' End Class ' '12. Class Hello ' MustOverride Function Hi() As String //can not have body as it is Mustoverridable ' Return "hi!" ' End Function ' End Class ' ' Class DragRacer ' Inherits Hello ' Overrides Function Hi() As String ' Return "Start your engines!" ' End Function ' End Class ' '14. Class Hello //Class must be declared MustInherit as all functions are MustOverride ' MustOverride Function Hi() As String ' End Class ' ' Class Euro ' Inherits Hello ' Overrides Function Hi() As String ' Return "Caio" ' End Function ' End Class ' '16. MustInherit Class Hello ' MustOverride Function Hi() As String ' End Class ' ' Class NorthEasterner ' Inherits Hello ' Overrides Runction Hi(ByVal name As String) As String //It is doing overloading. It must override Hi() and NOT Hi( with any parameter) ' Return "How ya doin', " & name ' End Function ' End Class