Implement the concept of overriding in console application

CODE:

Dim e As New employee

e.print()

Console.ReadLine()

End Sub

End Module

Imports System.Console

Public Class Person

Public name As String

Public city As String

Sub New()

name = "Sayali"

city = "Mumbai"

End Sub

Overridable Sub print()

Console.WriteLine(name)

Console.WriteLine(city)

End Sub

End Class

Public Class employee

Inherits Person

Public sal As Integer

Sub New()

sal = 8000

End Sub

Public Overrides Sub print()

MyBase.print()

Console.WriteLine(sal)

End Sub

End Class


No comments:

Post a Comment