FEDT VB.
NET
FRONT END DESIGN TOOL
USING
VB .NET
UNIT - 3
PRESENTATION BY:
ANKIT VERMA
(IT DEPARTMENT)
ANKIT VERMA ASS T. PROFESSOR
Interface
User interacts with application using well-defined user
interface.
Two types of interface:
CUI (Character User Interface)
Commands for user interaction
Not much user friendly
E.g. Console Application
GUI (Graphical User Interface)
No need to remember commands
Very easy to use & user friendly
E.g. Windows Application
28-11-2014 ANKIT VERMA 2
WINDOWS FORMS
28-11-2014 ANKIT VERMA 3
Windows Form
Accept input from user & display information.
Develop desktop based application.
Provides full support of database connectivity & image
formats.
System.Windows.Forms namespace support Form
Class.
Title Bar, Menu Bar & Control Box are at top of form.
Main area is called Client Area, surrounded by border.
Form associated controls enriched with predefined
Properties, Methods & Events.
28-11-2014 ANKIT VERMA 4
Windows Form
Properties
Define characteristics of controls like color, size, border etc.
Methods
Methods are defined by the action that an object can perform.
Events
These are actions that can be recognized by the objects.
Event occur when the user, OS or application interact with
objects of program.
They control the appearance & behavior of a form either at
design time or run time.
28-11-2014 ANKIT VERMA 5
Windows Form: Properties & Methods
Backcolor
BackgroundImage
FormBorderStyle
None
Fixed Single
Sizeable
Fixed Dialog
Fixed 3D
Fixed Tool Window
Sizeable Tool Window
MaximizeBox
28-11-2014 ANKIT VERMA 6
Windows Form: Properties & Methods
MaximizeBox
MinimizeBox
Text
WindowState
StartPosition
CenterParent
Manual
CenterScreen
WindowDefaultBounds
WindowDefaultLocation
28-11-2014 ANKIT VERMA 7
Windows Form: Properties & Methods
Activate
Close
Show
Refresh
Hide
Dispose
28-11-2014 ANKIT VERMA 8
Windows Form : Example
Example 1:
28-11-2014 ANKIT VERMA 9
Windows Form : Example
Example 2:
28-11-2014 ANKIT VERMA 10
Windows Form: Events
Activated
Deactivate
Click
Load
Closing
Closed
28-11-2014 ANKIT VERMA 11
MDI Forms
Display multiple windows at same time.
MDI form act as parent form or container for all other
forms, called MDI parent form.
Contain Menu Bar, Tool Bar and Status Bar.
E.g. Word
By default, VB.NET support SDI application, where
only one window displayed at a time.
E.g. Wordpad
In MDI Application, child forms are displayed as
independent windows under parent MDI window.
28-11-2014 ANKIT VERMA 12
MDI Forms
Create a form & set IsMDIContainer property true, it
will act as container.
Attach the menus to MIDI parent form.
Click event of menu item, write:
Form2.Show()
Add one more Form to project.
Write code on load of Second Form:
Me.MdiParent = Form1
Run the code & click on menu item.
28-11-2014 ANKIT VERMA 13
MDI Forms
28-11-2014 ANKIT VERMA 14
CONTROLS
28-11-2014 ANKIT VERMA 15
Controls
Major controls are:
Label Vscrollbar
Linklabel Picturebox
Textbox Timer
Button ListView
Checkbox TreeView
Listbox Panel
Radiobutton ToolBar
Combobox StatusBar
Groupbox
Hscrollbar
28-11-2014 ANKIT VERMA 16
Controls : Properties & Methods
Properties & Methods of controls are:
Backcolor Hide
Forecolor Show
Size Select
Enable Refresh
Locked
Visible
Location
Font
Maximum Size
Minimum Size
28-11-2014 ANKIT VERMA 17
Label
28-11-2014 ANKIT VERMA 18
Label
Graphic control used to display text.
User can’t edit text directly.
Text properties can be set at Run Time / Design Time.
It is in System.Windows.Form.Label class.
Label can’t receive focus.
Label Properties are:
AutoSize
BorderStyle
Enabled
Text Align
Text
28-11-2014 ANKIT VERMA 19
Label : Example
Example:
28-11-2014 ANKIT VERMA 20
Textbox
28-11-2014 ANKIT VERMA 21
Textbox
Accept input from user & retrieve data from database.
Textbox can be Multiline, Editable or ReadOnly.
It is subclass of System.Windows.Forms.TextBoxBase
Class.
28-11-2014 ANKIT VERMA 22
Textbox : Properties & Methods
Textbox Properties & Methods:
Borderstyle ScrollBars Text Cut
MaxLength SelectedText Clear Copy
PasswordChar TextAlign Select Paste
ReadOnly WordWrap SelectAll
MultiLine AppendText Show
Textbox Events:
GotFocus
LostFocus
Click
TextChanged
KeyPress
28-11-2014 ANKIT VERMA 23
Textbox : Example
Example:
28-11-2014 ANKIT VERMA 24
Link Label
28-11-2014 ANKIT VERMA 25
Link Label
Used to support hyperlinks.
Derived from Label class.
Link Label Properties:
ActiveLinkColor
LinkColor
VisitedLinkColor
LinkVisited
Link Label Event:
LinkClicked
28-11-2014 ANKIT VERMA 26
Link Label : Example
Example:
28-11-2014 ANKIT VERMA 27
Button
28-11-2014 ANKIT VERMA 28
Button
Buttons are the controls which are used for click even.
Button Properties:
Text
BackgroundImage
ImageAlign
TextAlign
Button Event:
Click
28-11-2014 ANKIT VERMA 29
Radio Button &
Check Box
28-11-2014 ANKIT VERMA 30
Radio Button
Radio button is used to select any one option at time.
These buttons are working in a group.
GroupBox control is used to group the related controls
together.
If we select a radio button from the group, the other
buttons can’t be select from the same group.
28-11-2014 ANKIT VERMA 31
Radio Button : Properties & Event
Radio Button Properties:
Text
AutoCheck
Radio Button Event:
Click
28-11-2014 ANKIT VERMA 32
CheckBox
Checkbox is used to set yes/no or true/false options.
User can select one option at a time.
When we select a checkbox, a right mark appears in it,
indicating that the box is selected.
The image and text both can be displayed in the
CheckBox control.
28-11-2014 ANKIT VERMA 33
CheckBox : Properties & Event
CheckBox Properties:
Text
AutoCheck
Checked
ThreeState
CheckState
CheckBox Event:
CheckedChanged
28-11-2014 ANKIT VERMA 34
RadioButton & CheckBox : Example
Example:
28-11-2014 ANKIT VERMA 35
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 36
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 37
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 38
List Box &
Combo Box
28-11-2014 ANKIT VERMA 39
ListBox
Display list of items to user.
User can select one or more items from list box.
Scroll bar appears automatically if the list has too
many items.
User can add items to control using Design Time or
Run Time.
28-11-2014 ANKIT VERMA 40
ListBox : Properties & Events
ListBox Properties:
SelectionMode Clear
Sorted Contains
SelectedIndex Insert
SelectedItem IndexOf
MultiColumn Remove
Items RemoveAt
Add
ListBox Event:
SelectedIndexChanged
28-11-2014 ANKIT VERMA 41
ComboBox
It is used to display a drop down list of items.
It is combination of a textbox in which user enters an
item & drop down list from which user selects an item.
28-11-2014 ANKIT VERMA 42
ComboBox : Properties & Events
ComboBox Properties:
Sorted Clear
MaxLength Contains
SelectedIndex Insert
SelectedItem IndexOf
Items Remove
Text RemoveAt
Add
ComboBox Event:
SelectedIndexChanged
28-11-2014 ANKIT VERMA 43
ListBox & ComboBox : Example
Example:
28-11-2014 ANKIT VERMA 44
ListBox & ComboBox : Example
28-11-2014 ANKIT VERMA 45
ListBox & ComboBox : Example
28-11-2014 ANKIT VERMA 46
Picture Box &
Timer Control
28-11-2014 ANKIT VERMA 47
PictureBox
Used to display images, handling images, editing
images.
Image can be added at Run Time as well as at Design
Time.
PictureBox Properties & Methods:
Image
BorderStyle
SizeMode
Load
PictureBox Event:
MouseDown
28-11-2014 ANKIT VERMA 48
Timer Control
Used to create periodic events.
This control is not visible at Run Time.
It work behind the scenes.
TimerControl Properties & Methods:
Enable
Interval
Start
Stop
TimerControl Event:
Tick
28-11-2014 ANKIT VERMA 49
PictureBox & Timer Control : Example
Example:
28-11-2014 ANKIT VERMA 50
PictureBox & Timer Control : Example
28-11-2014 ANKIT VERMA 51
PictureBox & Timer Control : Example
28-11-2014 ANKIT VERMA 52
HScrollBar &
VScrollBar
28-11-2014 ANKIT VERMA 53
HScrollBar & VScrollBar
Scroll Bars are Vertical & Horizontal controls that display a
Srcoll Box or Thumb that we can manipulate.
The value of Scroll Bar changes when we drag the Thumb into
new position.
ScrollBar Properties:
Value
Minimum
Maximum
LargeChange
SmallChange
ScrollBar Event
ScrollValueChanged:
28-11-2014 ANKIT VERMA 54
HScrollBar : Example
Example:
28-11-2014 ANKIT VERMA 55
Panel
28-11-2014 ANKIT VERMA 56
Panel
Panel is used to group other controls.
It divide the form into different regions.
Panel Control have scrollbars.
Panel Control Properties:
AutoScroll
BorderStyle
28-11-2014 ANKIT VERMA 57
Panel
Example:
28-11-2014 ANKIT VERMA 58
Menus
28-11-2014 ANKIT VERMA 59
Menus
Provide consistent way to group commands so that
user can access them very easily.
MenuScript control is used to create menus.
Menus are user friendly and interactive.
Menu Item Properties:
Checked
DisplayStyle
Enable
ShortCutKeys
Visible
28-11-2014 ANKIT VERMA 60
Menus
Example:
28-11-2014 ANKIT VERMA 61
Exception Handling
28-11-2014 ANKIT VERMA 62
Exception Handling : Types
Types of Exception Handling
Structured Exception Handling
Structured Exception Handling is included in VB.NET
E.g. When we open a file & file not exist, exception raised and
handled by system itself.
Un-structured Exceptional Handling
Un-structured Exceptional Handling of Visual Basic is still
supported in VB.NET.
Exception class in system namespace is base class of
all Exceptions.
28-11-2014 ANKIT VERMA 63
Exception Handling : Error Types
Three types of Errors:
Syntax
Appear when we write the wrong Syntax.
Easily fixed in .NET
Runtime
Appear only when we Compile & Run the code.
Logical
Appear when we use the application, but producing wrong result.
28-11-2014 ANKIT VERMA 64
Exception Handling : System Defined
System defined exceptions are:
Exception
Index Out Of Range Exception
Null Reference Exception
Argument Exception
Arithmetic Exception
28-11-2014 ANKIT VERMA 65
Exception Handling : Syntax
Syntax:
Try
Catch [exception as type]
Catch [exception as type]
Finally
[finally statement]
End Try
28-11-2014 ANKIT VERMA 66
Exception Handling
Example:
28-11-2014 ANKIT VERMA 67
User Defined Exception
Example:
28-11-2014 ANKIT VERMA 68
ADVANCED CONTROLS
28-11-2014 ANKIT VERMA 69
List View
28-11-2014 ANKIT VERMA 70
List View
Used to display items.
E.g. Window Explorer right pane
User can view items in different modes:
LargeIcon
SmallIcon
List
Title
Details
28-11-2014 ANKIT VERMA 71
List View : Properties & Methods
ListView Properties & Methods:
AllowColumnReorder MultiSelect
AutoArrange Sorting
CheckBoxes View
Columns ArrangeIcons
GridLines Clear
Items GetItemAt
LabelEdit
ListView Event:
SelectedIndexChanged
28-11-2014 ANKIT VERMA 72
List View : Example
Example:
28-11-2014 ANKIT VERMA 73
List View : Example
Example:
28-11-2014 ANKIT VERMA 74
Tree View
28-11-2014 ANKIT VERMA 75
Tree View
Display hierarchy of nodes.
Each node can have child nodes also.
E.g. Window explorer leftpane
28-11-2014 ANKIT VERMA 76
Tree View : Properties & Events
TreeView Properties & Methods:
CheckBoxes ShowLines
FullRowSelcet ShowRootLines
LabelEdit Sorted
Nodes TopNode
Scrollable CollapseAll
SelectedNode ExpandAll
GetNodeCount
TreeView Events:
AfterCollapse AfterExpand
BeforeCollapse BeforeExpand
28-11-2014 ANKIT VERMA 77
Tree View : Example
Example:
28-11-2014 ANKIT VERMA 78
ToolBar
28-11-2014 ANKIT VERMA 79
ToolBar
Placed after menu bar & consist of buttons.
Different types of buttons can be created in toolbar.
Standard Push Button
Toggle Button
Drop Down Button
Separators
Toolbar are usually docked along the top of its parent
window.
Display tool tips when the user points the mouse
pointer at toolbar button.
28-11-2014 ANKIT VERMA 80
ToolBar : Properties & Events
ToolBar Properties & Methods:
Appearance
AutoSize
Buttons
Divider
ShowToolTips
TextAlign
Wrappable
ToolBar Events:
ButtonClick
28-11-2014 ANKIT VERMA 81
Status Bar
28-11-2014 ANKIT VERMA 82
StatusBar
Appear at bottom of window.
Display panels or simple status bar to display single
message on bar.
StatusBar Properties & Methods:
BackgroundImage
Font
Panels
ShowPanels
StatusBar Events:
PanelClick
28-11-2014 ANKIT VERMA 83
Common Dialog Control
28-11-2014 ANKIT VERMA 84
Common Dialog Control
Window application use standard dialog boxes for
common operations.
These are implemented as standard control in toolbox.
They are not visible at Run Time.
Five types of dialog controls in toolbox under dialog
tabs:
ColorDialog
FolderBrowserDialog
FontDialog
OpenFileDialog
SaveFileDialog
28-11-2014 ANKIT VERMA 85
Common Dialog Control : Color Dialog
Color Dialog is for selecting colors from list of colors.
ColorDialog Properties & Methods:
Color
CustomColors
FullOpen
ShowHelp
Reset
ShowDialog
28-11-2014 ANKIT VERMA 86
Common Dialog Control : Folder Browser Dialog
Folder Browser Dialog is used to select the folder.
FolderBrowserDialog Properties & Methods:
RootFolder
SelectPath
ShowNewFolderButton
Reset
ShowDialog
28-11-2014 ANKIT VERMA 87
Common Dialog Control : Font Dialog
Font Dialog is similar to Font Dialog of MS Word.
User can Select the font, style etc.
FontDialog Properties & Methods:
Color
Font
MaxSize
MinSize
ShowApply
ShowColor
ShowHelp
Reset
ShowDialog
28-11-2014 ANKIT VERMA 88
Color Dialog & Font Dialog : Example
Example:
28-11-2014 ANKIT VERMA 89
Common Dialog Control
28-11-2014 ANKIT VERMA 90
Common Dialog Control :
Open File Dialog & Save File Dialog
OpenFileDialog is used for selection of file to open.
SaveFileDialog is used to select or specify the path of a
file in which current document will be saved.
Properties & Methods:
AddExtension OpenFile
DefaultExt Reset
FileName ShowDialog
Filter ShowReadOnly
MultiSelect Show Help
28-11-2014 ANKIT VERMA 91
Folder Browser Dialog : Example
Example:
28-11-2014 ANKIT VERMA 92
Creating User Controls
28-11-2014 ANKIT VERMA 93
Creating User Controls
All windows form controls are reusable components
and they are used for window based application.
We can create our own control other than existing.
We can combine existing & our own custom control.
Two main classes used for creating custom controls:
Control Class
Provide all basic functionality for the windows user.
Handles user input through keyboard, mouse etc.
User Class
It is inherited child of control class.
Provide empty control that can be used to create other control.
28-11-2014 ANKIT VERMA 94
Creating User Controls : Types Of Controls
There are three types of controls that can be created:
Composite Control
It is collection of Windows Form controls contained in single
container.
Also called Constituent Controls.
Extended Control
In this, we derive an inherited control from the existing one.
In this approach, we can retain all the functionality of parent control
and extend those functionality by adding our own custom properties
& methods.
Custom Control
This is new control from the beginning by inheriting from Control
Class.
28-11-2014 ANKIT VERMA 95
Creating User Controls : Example
Creating User Control (Button):
28-11-2014 ANKIT VERMA 96
Creating User Controls : Example
Import User Control (Button):
28-11-2014 ANKIT VERMA 97
Creating User Controls : Example
28-11-2014 ANKIT VERMA 98
Creating User Controls : Example
28-11-2014 ANKIT VERMA 99
Creating User Controls : Example
28-11-2014 ANKIT VERMA 100
OBJECT ORIENTED
CONCEPTS
28-11-2014 ANKIT VERMA 101
Object Oriented Concepts
VB.NET is an Object Oriented Programming language
with features:
Abstraction
Encapsulation
Polymorphism
Inheritance
It also support following:
Overloading
Overriding
Structure
Class
28-11-2014 ANKIT VERMA 102
Class
Class is generally called a Blueprint or User Defined
Data Type.
Class is collection of objects of similar type.
Class consists of Attributes (Data Members) and
Behaviors (Member Functions), that are used by
Instances of that class.
Class is an Abstract entity.
Members of Class:
Data Members, Properties, Methods & Events
Class Access Specifiers:
Public, Private, Protected, Friend & Protected Friend
28-11-2014 ANKIT VERMA 103
Object
Objects are Real Time entity.
They may present as Person, Place, Bank Account, Table of
Data, Item etc.
It is Instance of class.
Each object contain data & code to manipulate data.
Two types of data members:
Static or Class Member
Members that apply to Class and called by their class names.
Shared keyword is used with members.
Instance or Object Member
Members that apply to object.
They referred by object name.
28-11-2014 ANKIT VERMA 104
Overloading & Overriding
Overloading
Provide different versions of a method that has same name &
different parameters.
Parameters can be different from name, data type or ordering of
parameters.
Overriding
Replace inherited property or method.
Overridden methods in subclass must be same as base class
method including name and parameters.
28-11-2014 ANKIT VERMA 105
Class Object Example
Example:
28-11-2014 ANKIT VERMA 106
Constructor
Special methods that allow control over initialization
of objects.
Constructors are Procedures with name Sub New.
Run when Instance of class is created.
Explicitly called only from other Constructors.
Parameterized Constructors:
Parameters can be passed to constructors also.
Shared Constructors can’t have parameters.
28-11-2014 ANKIT VERMA 107
Constructor Types
Two types of Constructors:
Shared Constructors
Used to initialize Shared variables.
Created using Shared keyword & shared with all instance of class.
Not run more than one, during single execution of program.
Explicitly Public access & we can’t write explicitly.
We can’t initialize Instance variable in Constructor.
Instance Constructors
Initialize variable that are declared with Dim, Public, Private,
Friend, Protected etc.
You can also access Shared variable within this.
28-11-2014 ANKIT VERMA 108
Constructor Example
28-11-2014 ANKIT VERMA 109
Destructor
Special method used to release Objects from memory.
Two types of Destructors:
Finalize Method
Called from the class or derived class, to which it belong.
Called after last reference to an Object is released from Memory.
.NET automatically runs Finalize Destructor.
We can’t determine it’s execution, when an Object loses its scope.
CLR calls this using system call called Garbage Collection.
CLR periodically check for Object, if Object not used, this Destructor
is called automatically and Garbage Collection Starts.
Finalize method is Overridden when we write our code Explicitly.
Dispose
28-11-2014 ANKIT VERMA 110
Destructor
Dispose Method
Problem with Finalize Method is non deterministic nature.
We can’t determine Finalize Method call explicitly.
Dispose Method is called to release resource such as Database
Connection, File Handler or System Lock.
Unlike Finalize Method, this is not called Automatically.
Through code we have to call this Explicitly.
Example:
Protected Overrides Sub Finalize ( )
MsgBox (“Object Out Of Scope”)
EndSub
28-11-2014 ANKIT VERMA 111
Structure
It is User Defined Data Type.
Structure combines Variables & Methods.
Single Variable of Structure can hold different types of data.
Structure can be declared Inside Class, Namespace, Module
or Another Structure.
Access Specifiers are allowed for Structure & their members.
Only Shared Members & Constants can be Initialized.
Like Class, Structure have Constructors but only
parameterized.
If we have Default Constructor, that must be declared as Shared one.
28-11-2014 ANKIT VERMA 112
Structure Example
Example:
28-11-2014 ANKIT VERMA 113
Structure With Constructor Example
Example:
28-11-2014 ANKIT VERMA 114
Class VS Structure
Similarities:
Both are User Defined Data Types.
Both support members like Constructor, Variables, Constants,
Methods, Events etc.
Both have Shared Constructors with or without parameters.
Both can implement Interfaces.
28-11-2014 ANKIT VERMA 115
Class vs Structure
Differences:
Class can be Inherited from other Class, but Structure not.
Class can have Instance Constructors with and without
parameters, but Structure only have parameterized.
Class is Reference type, but Structure is Value type.
Class allow initialization of members inside Class, but Structure
not allow inside initialization.
Class have Private as default Access Specifier for all variables &
constants, but Structure have Public by default.
Class Procedures can handle Events, but not in Structure.
28-11-2014 ANKIT VERMA 116
Method Overloaing
28-11-2014 ANKIT VERMA 117
Method Overloading
Overloading Methods have same name, but different
argument lists.
Argument may differ in Type, Number or Order Of
The Parameter.
Return type of Overloading Method can be Same or
Different.
Method invoked depends upon the type of argument
passed.
Overloading is example of Polymorphism.
28-11-2014 ANKIT VERMA 118
Method Overloading : Example
28-11-2014 ANKIT VERMA 119
Shared Members
28-11-2014 ANKIT VERMA 120
Shared Members
Shared keyword can be used with Constructor,
Methods & Variables.
Shared methods can be overloaded like regular
methods.
Shared variables create only one copy for all instances
of class.
28-11-2014 ANKIT VERMA 121
Shared Members : Example
Example:
28-11-2014 ANKIT VERMA 122
Inheritance
28-11-2014 ANKIT VERMA 123
Inheritance
Inheritance refers to deriving new Class from existing Class.
Derived Class is known as Sub Class and Parent Class is
known as Base Class.
Derived Class inherits all Public & Protected Data Members,
Methods, Events & Constants.
Constructor can’t be inherited.
Types of Inheritance:
Single
Multi Level
Hierarchical
Multiple Inheritance only supported by using Interface
28-11-2014 ANKIT VERMA 124
Inheritance : Keywords
Inherits
Inherits keyword is used to inherit Class.
MustInherit
Indicate that Class must be inherited by other Class.
It act as Base Class and similar to Abstract Class of Java.
NonInheritable
If class is marked NonInheritable, we can’t create its Sub Class
MyBase
Call parent Class Constructor and Parent Class Overridden Methods.
It always refers the immediate Super Class.
We can’t navigate to more than one level from the Child Class.
MyBase.MethodName is not allowed in .NET
28-11-2014 ANKIT VERMA 125
Inheritance : Keywords
Overloads
Indicate that methods are Overloading.
If Methods are in same class, no necessary to write this keyword.
Overridable
Allow method to be Overridden.
Overrides keyword is used to override the Overridable Method.
NotOverridable
Prevent the method being Overridden.
MustOverride
Methods must be declared in MultiInherit Class.
MustInherit
Enable Abstract Class creation. Child Class must implement all Abstract
Methods, otherwise Child Class also must declared as Abstract Class.
28-11-2014 ANKIT VERMA 126
Inheritance : Example
Example:
28-11-2014 ANKIT VERMA 127
Inheritance : Example
28-11-2014 ANKIT VERMA 128
Inheritance : Example
28-11-2014 ANKIT VERMA 129
Method Overriding
28-11-2014 ANKIT VERMA 130
Method Overriding
Sub Class is not only Inheriting but it can also give its
own implementation (override) for methods.
All the methods can’t be Overridden.
To allow methods to Overridden, Parent Class method
must use Overridable keyword.
28-11-2014 ANKIT VERMA 131
Method Overriding : Example
28-11-2014 ANKIT VERMA 132
Abstract
Base Class
28-11-2014 ANKIT VERMA 133
Abstract Base Class
MustInherit keyword is used to create Abstract Class.
Contain Signature of method, that Derived Class can
implement in its own Class.
We can’t create Object of it.
Method with MustOverride keyword should not
contain any implementation.
Class with even one MustOverride method, should be
declared as MustInherit.
To implement method, Overrides keyword use in Sub
Class.
28-11-2014 ANKIT VERMA 134
Abstract Base Class
If Sub Class is not implementing any one of Abstract
methods from Abstract Class, then Child Class must
be declared as Abstract one.
Abstract Class can contain Non-Abstract Method also.
28-11-2014 ANKIT VERMA 135
Abstract Base Class : Example
Example:
28-11-2014 ANKIT VERMA 136
Interface
28-11-2014 ANKIT VERMA 137
Interface
Interface defines Properties, Method and Events, called
members of Interface.
Interface consist of only Declaration of Members but not
the Implementation.
Only Class and Structure implement these data
members.
Variables can’t be declared in the Interface.
Single Class can inherit from only one Base Class, but
can implement any number of Interfaces.
It support Multiple Inheritance.
Implements keyword is used for their implementation.
28-11-2014 ANKIT VERMA 138
Interface Vs Class
Interface can’t provide any implementation, whereas
Class can provide implementation to Methods.
Interface can’t have Constructors, but Class can define
Constructors.
A Class inherits from only one Class, but implements
multiple Interface.
28-11-2014 ANKIT VERMA 139
Interface : Example
Example:
28-11-2014 ANKIT VERMA 140
THANKYOU
DOUBTS
PRESENTATION BY:
ANKIT VERMA
(IT DEPARTMENT)
ANKIT VERMA ASS T. PROFESSOR