·
IT ACCESS BY REFERENCE
·
IN IT WE ARRANGE THE NAMING FUNCTION
·
WE NEVER CREATE THE BODY OF THE FUNCTION
·
IT IS USED TO CREATE THE ARCHITECTURE OF THE
FUNCTION
·
THIS TECHNIQUE IS USED TO REPRESENT THE NAMING
ARCHITECTURE
·
INTERFACE ARE IMPLEMNETED IN THE CLASS
·
IN INTERFACE WE CAN USE MULTIPLE AND HYBRID
CONCEPT OF INHERITANCE
BOUNDARIES
·
IN INTERFACE METHOD IS OF ABSTRACT TYPE
·
INTERFACE IS BY DEFAULT PUBLIC KEYWORD SO NO NEED
TO USED ACCESS MODIFIERS ON FUNTIONS
ON CLASS
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
WindowsFormsApplication7
{
public interface abc
{
int
sum(int a, int
b);
int
sub(int a, int
b);
}
public interface abcd
{
void
hello();
int
div(int a, int
b);
}
class Class1:abc,abcd
{
public int sum(int a, int b)
{
return
a + b;
}
public int sub(int a, int b)
{
return
a - b;
}
public int div(int a, int b)
{
return
a / b;
}
public void hello()
{
System.Windows.Forms.MessageBox.Show("hello how are you");
}
}
}
ON BUTTON
private void button1_Click(object
sender, EventArgs e)
{
Class1
ob = new Class1();
MessageBox.Show(ob.sum(12,
34).ToString());
MessageBox.Show(ob.sub(23,
11).ToString());
MessageBox.Show(ob.div(24,
6).ToString());
ob.hello();
}
ABSTRACT
·
Abstract class is a class that has no direct instances,
but whose descendants may have direct instances
·
WE CANNOT
CREATE THE OBJECT OF ABSTRACT CLASS
·
WE CAN
DEFINE ABSTRACT AND NON ABSTRACT BOTH METHODS
·
IT IS AN
ADVANCE IMPROVMENTS ON INTERFACE
·
USE OF
ABSTRACT KEYWORD IS NECESSARY
·
BY
DEFINITION IT IS ABSTRACT CLASS IF WE USED ABSTRACT KEYWORD IN ANY CLASS BUT
NOT BY CODING
·
An abstract class cannot
be a sealed class.
·
Use of virtual keyword is necessary on functions to override
them in derived class
·
Use of abstract keyword is necessary to define abtract type
functions means which has no body;
Abstract class aa
{
Public abstract int xyz();
}
Non
abstract
Public int abc()
{
}
}
If you HAVE
MAKE THE BASE CLASS AN ABSTRACT CLASS THAN HAVE TO USED THE OVERRIDE KEYWORD IN
THE DERIVED CLASS
Practical
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
WindowsFormsApplication7
{
abstract class Class2
{
public int sum(int a, int b)
{
return
a + b;
}
public virtual int div(int a, int b)
{
return
a / b;
}
public virtual int mul(int a, int b)
{
return
a * b;
}
public abstract int aa(int a, int b);
}
class pawan : Class2
{
public override int aa(int a, int b)
{
return
a % b;
}
public override int div(int a, int b)
{
return
a / b;
}
}
}
No comments:
Post a Comment