Public MustInherit Class Class1
Public n As Integer
Sub New()
Console.WriteLine("Inside Abstract CLass1 Constructor...")
Console.Write("Enter a number = ")
n = CInt(Console.ReadLine)
End Sub
MustOverride Sub display()
End Class
Public Class Class2 : Inherits Class1
Public Overrides Sub display()
Console.WriteLine("n= " + n.ToString())
End Sub
End Class
Module AbstractClassExample
Sub Main()
Dim obj As Class1
Dim obj1 As New Class2
obj = obj1
obj.display()
Console.ReadLine()
End Sub
End Module
Output:
Inside Abstract CLass1 Constructor...
Enter a number = 2
n= 2
VBasic Code Examples
ReplyDelete