Basic OOPs programming concepts in VB.NET

Rate this article
5.00 out of 5
In this video tutorial, we will familiarize you with some of the basic object oriented concepts like Inheritance and polymorphism in VB.NET. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.

Polymorphism
Inheritance
Source Code
Module1.vb
Module Module1
    Class Person 'base class
        Private strName As String 'strName as a private member
        Public intAge As Integer 'intAge as a public member
        Public Function getName()
            Return strName
        End Function
        Public Function getAge()
            Return intAge
        End Function
        Public Sub setName(ByVal name As String)
            strName = name
        End Sub
        Public Overridable Sub Play()
            System.Console.WriteLine("I Play Nothing")
        End Sub
    End Class
    Class CricketPlayer 'derived class
        Inherits Person 'the keyword "Inherits" is used to inherit from a class
        Public strNationality As String 'derived classes member
        Function getNationality()
            Return strNationality
        End Function
        Public Overrides Sub Play()
            System.Console.WriteLine("I can Play Cricket")
        End Sub
    End Class
    Sub Main()
        System.Console.WriteLine("Polymorphism Example")
        Dim Player As New CricketPlayer
        System.Console.WriteLine()
        Player.Play()
        Dim Person1 As New Person
        System.Console.WriteLine()
        Person1.Play()
        Dim CricPlayer As New CricketPlayer
        Dim person2 As Person
        person2 = CricPlayer
        System.Console.WriteLine()
        person2.Play()
        System.Console.WriteLine()
    End Sub

End Module



Download Source Code Of Polymorphism

Download Source Code Of Inheritance

Joined Date :14-Nov-2012
Articles
Posted
60
Messages
Posted
3

KTS InfoTech Training division offers various short-term programming courses for Students and Professionals who are looking for a bright career in the field of Software development.

The programming video tutorials presented in this web site are taken from some of the training sessions conducted by KTS InfoTech.

You can also learn the Programming packages through Internet directly form our English Speaking Technical experts at an affordable rate.

For more details click here and submit your training requirements.




   
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud