Object Oriented Programming Concepts
Object Oriented Programming
Objects vs. Structures
Methods, Events, and Properties
Overloading
Interfaces and Inheritance
Objects
Abstraction
Encapsulation
Polymorphism
Inheritance
Object Components
Public Structure Person
Public Appendages As Integer
Public Male As Boolean
Public EyeColor As Color
End Structure
Public Class Person
Public Appendages As Integer
Public Male As Boolean
Public EyeColor As Color
End Class
1. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Affiliated G.G.S.IP.U, Delhi
BCA, FEDT VB .NET,20205
Priyanka Rattan
Assistant Professor(IT)
2. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Topic
Object Oriented Programming Concepts
–Object Oriented Programming
–Objects vs. Structures
–Methods, Events, and Properties
–Overloading
–Interfaces and Inheritance
3. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Object Oriented Programming
• Objects
• Abstraction
• Encapsulation
• Polymorphism
• Inheritance
4. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Object Components
The Object
• Data
– Members
– Properties
• Behavior
– Methods
– Events
5. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Objects vs. Structures
Public Structure Person
Public Appendages As Integer
Public Male As Boolean
Public EyeColor As Color
End Structure
Public Class Person
Public Appendages As Integer
Public Male As Boolean
Public EyeColor As Color
End Class
6. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Properties and Events
• Every Control has a set of properties, methods and
events associated with it
• Eg Form
– Properties
• Name (program will use this name to refer)
• Text (title of the form)
– Methods
• Show
• Hide
• Close
– Events
• Load
• UnLoad
7. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Constructor
• Used for initializing private members of a class
• Name of the constructor should be New() always
• Can have zero or more parameters
• Does not return any value. So they are sub routines
• Need not be invoked explicitly. They are invoked
automatically when an object is created
• A class can have more than one constructor
• Every constructor should differ from the other by
means of number of parameters or data types of
parameters
• Constructors can be inherited
8. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Destructor
• Used for releasing memory consumed by objects
• Name of the destructor should be Finalize() and the
method is already defined in CLR. So we can only
override it.
• Does not return any value. Hence it is a subroutine
• Does not accept any parameters
• Only one destructor for a class
• Destructors are not inherited
• No need of explicit invocation. They are called when
the execution is about to finish.
9. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Array List
• Array List is a dynamic array
• Its size grows with the addition of element
• Searching is based on the index
• Sequential search is performed on elements
• Hence it is slow
• Occupies less space
10. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Forms and other controls
• Form is a container for other controls
• We can place the following in a form
– Label
– Text Box
– Check Box
– Radio Button
– Button
– Date Picker
– And more…
11. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Exception Handling
• Exception is Run time error
• It is not known at the compile time
• Examples of exceptions
– Divide by zero
– Accessing non existing portion of memory
– Memory overflow due to looping
• In VB .Net, exception is handled via Try Catch
Mechanism
12. TRINITY INSTITUTE OF PROFESSIONAL STUDIES
Sector – 9, Dwarka Institutional Area, New Delhi-75
Try Catch Finally
Try
Suspicious code that may throw an exception to
be written here
Catch ex As Exception
What to be done if exception occurs to be written
here
Finally
Optional portion which will be executed
irrespective of the happening of exception to be
written here. Can contain code for releasing
unnecessary space