VB.Net program to demonstrate the interface inheritance

Here, we are going to demonstrate the interface inheritance in VB.Net.
Submitted by Nidhi, on December 27, 2020

Here, we will create an interface ISample1 and then inherit the ISample1 into the ISample2 interface. After that, we will implement the interface ISample2 inside the Sample class.

Program/Source Code:

The source code to demonstrate the interface inheritance is given below. The given program is compiled and executed successfully.

' program to demonstrate the interface inheritance.

Module Module1
    Interface ISample1
        Sub Fun1()
    End Interface

    Interface ISample2
        Inherits ISample1
        Sub Fun2()
    End Interface

    Class Sample
        Implements ISample2

        Sub Fun1() Implements ISample2.Fun1
            Console.WriteLine("Fun1() called")
        End Sub

        Sub Fun2() Implements ISample2.Fun2
            Console.WriteLine("Fun2() called")
        End Sub

    End Class

    Sub Main()
        Dim S As New Sample()
    End Sub
End Module


Fun1() called
Fun2() called
Press any key to continue . . .


In the above program, we created a module Module1. Here, we inherited the ISample1 interface inside another interface ISample2. Then we implemented interface ISample2 inside the Sample class.

At last, we created a Main() function, which is the entry point for the program, here we created the object of Sample class and called the Fun1(), Fun2() methods that will print an appropriate message on the console screen.

VB.Net Basic Programs »



Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.