using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OopsConcept
{
/// <summary>
/// An Abstract class doesn't provide full abstraction but an interface does provide full abstraction; i.e. both a declaration and a definition is given in an abstract class but not so in an interface.
//Using Abstract we can not achieve multiple inheritance but using an Interface we can achieve multiple inheritance.
//We can not declare a member field in an Interface.
//We can not use any access modifier i.e. public , private , protected , internal etc. because within an interface by default everything is public.
//An Interface member cannot be defined using the keyword static, virtual, abstract or sealed.
/*
* Abstraction:
Abstraction is "To represent the essential feature without representing the back ground details."
Abstraction lets you focus on what the object does instead of how it does it.
Abstraction provides you a generalized view of your classes or object by providing relevant information.
Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner.
Real world Example of Abstraction: -
Suppose you have an object Mobile Phone.
Suppose you have 3 mobile phones as following:-
Nokia 1400 (Features:- Calling, SMS)
Nokia 2700 (Features:- Calling, SMS, FM Radio, MP3, Camera)
Black Berry (Features:-Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)
Abstract information (Necessary and Common Information) for the object "Mobile Phone" is make a call to any number and can send SMS."
so that, for mobile phone object you will have abstract class like following:-
*
/// ENCAPSULATION START HERE
*
*
*
* Encapsulation:
Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation.
Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.
Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions.
class Bag
{
book;
pen;
ReadBook();
}
Encapsulation means hiding the internal details of an object, i.e. how an object does something.
Encapsulation prevents clients from seeing its inside view, where the behaviour of the abstraction is implemented.
Encapsulation is a technique used to protect the information in an object from the other object.
Hide the data for security such as making the variables as private, and expose the property to access the private data which would be public.
So, when you access the property you can validate the data and set it.
S
*/
/// </summary>
abstract class M1
{
public int add(int a, int b)
{
return (a + b);
}
}
class M2 :M1
{
//public int mul(int a, int b)
//{
// return a * b;
//}
}
class test
{
static void Main56(string[] args)
{
M2 ob = new M2();
int result = ob.add(10, 20);
Console.WriteLine("the result is {0}", result);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OopsConcept
{
/// <summary>
/// An Abstract class doesn't provide full abstraction but an interface does provide full abstraction; i.e. both a declaration and a definition is given in an abstract class but not so in an interface.
//Using Abstract we can not achieve multiple inheritance but using an Interface we can achieve multiple inheritance.
//We can not declare a member field in an Interface.
//We can not use any access modifier i.e. public , private , protected , internal etc. because within an interface by default everything is public.
//An Interface member cannot be defined using the keyword static, virtual, abstract or sealed.
/*
* Abstraction:
Abstraction is "To represent the essential feature without representing the back ground details."
Abstraction lets you focus on what the object does instead of how it does it.
Abstraction provides you a generalized view of your classes or object by providing relevant information.
Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner.
Real world Example of Abstraction: -
Suppose you have an object Mobile Phone.
Suppose you have 3 mobile phones as following:-
Nokia 1400 (Features:- Calling, SMS)
Nokia 2700 (Features:- Calling, SMS, FM Radio, MP3, Camera)
Black Berry (Features:-Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)
Abstract information (Necessary and Common Information) for the object "Mobile Phone" is make a call to any number and can send SMS."
so that, for mobile phone object you will have abstract class like following:-
*
/// ENCAPSULATION START HERE
*
*
*
* Encapsulation:
Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation.
Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.
Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions.
class Bag
{
book;
pen;
ReadBook();
}
Encapsulation means hiding the internal details of an object, i.e. how an object does something.
Encapsulation prevents clients from seeing its inside view, where the behaviour of the abstraction is implemented.
Encapsulation is a technique used to protect the information in an object from the other object.
Hide the data for security such as making the variables as private, and expose the property to access the private data which would be public.
So, when you access the property you can validate the data and set it.
S
*/
/// </summary>
abstract class M1
{
public int add(int a, int b)
{
return (a + b);
}
}
class M2 :M1
{
//public int mul(int a, int b)
//{
// return a * b;
//}
}
class test
{
static void Main56(string[] args)
{
M2 ob = new M2();
int result = ob.add(10, 20);
Console.WriteLine("the result is {0}", result);
Console.ReadLine();
}
}
}
No comments:
Post a Comment