vb syntax question 1

Hello all,

  My boss is doing a fun little VB quiz with 3 questions to all of his C# programmer teams and the winner gets lunch on him. :)  I would love to have a steak lunch today so any assistance would be appriciated.

He has given us some code and wants us to find the errors I will post below what I have and what I believe is wrong if you could verrify that would be great

Qustion 1

Public Class hello

Function Hi() As String

Return "Hey"

End Function

End Class

 

' I cant find anything wrong with this code other than the fact that there is no imput for the

' function to access i.e. button press

''

Question 2

Class Hello2

MustOverride Function Hi() As String

Return "hi!"

End Function

End Class

' In this code I have found 2 errors

' error 1 the class hello2 should be declared mustinherit because it contains methods mustoverride

' error 2 shouldent Endfunction be mustoverride end function or am I wrong

 

Question 3

Class hello3

MustInherit Function Hi() As String

 

End Class

Class Gentleman

Inherits hello3

Overrides Function Hi() As String

Return "Good Day"

End Function

End Class

'' should the MustInherit be taken out and it be left as Function Hi() As String

'' Overrides function Hi can not overide because the function is not defined as overridable correct?



HawaiiDragonAsked:
Who is Participating?
 
CodeCruiserCommented:
Q1: No modifier on function (public/private/friend)
Q2: Your point 1 is correct. Point 2 no.
Q3: MustInherit applies to class not function.
0
 
HawaiiDragonAuthor Commented:
Myself and 5 others thank you!!!!
0
 
CodeCruiserCommented:
So you got the lunch then?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.