OOP: Understanding Abstraction

I looked through many articles and some questions for a better understanding abstraction, but got a little confused. This is what I read: here

Abstraction - “Represent an essential function without presenting background details. Abstraction allows you to focus on what the object is doing instead of how it does it.

Specified Code:

abstract class MobilePhone
}
    public void Calling();
    public void SendSMS();
}

public class Nokia1400 : MobilePhone
{

}

public class Nokia2700 : MobilePhone
{
    public void FMRadio();
    public void MP3();
    public void Camera();
}

My question is that when we inherit abstract class, we do not implement the details in our subclasses?
call () and sendSms () have no implementation in the super type, so when we implement it in our subclass, we also need to know the background data. So how does Abstraction really work in this example?

Edit : if you buy some help here, these guys gave the best answers: Difficulty Sergey Berezovsky

+4
7

, .

  • , . , . , , virtual. , , :

:

abstract class MobilePhone
{
    public abstract void Calling();
    public abstract void SendSMS();
}

, :

abstract class MobilePhone
{
    public virtual void Calling()
    {
        // Code goes here.
    }

    public virtual void SendSMS()
    {
        // Code goes here.
    }
}

, :

abstract class MobilePhone
{
    public void Calling()
    {
        // Code goes here.
    }

    public void SendSMS()
    {
        // Code goes here.
    }
}

. , , Nokia1400 Nokia2700 , , .

, , , , , :

  • , .
  • , , .

, , . , , .

, :

public abstract class MobilePhone
{
    public virtual void Calling()
    {
        Console.Write("Calling");
    }

    public abstract void SendSMS();
}

public class Nokia1400 : MobilePhone
{
    public override void SendSMS()
    {
        Console.WriteLine("Sending SMS from Nokia 1400.");
    }
}

public class Nokia2700 : MobilePhone
{
    public void FMRadio()
    {
        Console.WriteLine("FM Radio");
    }

    public void MP3()
    {
        Console.Write("MP3");
    }

    public void Camera()
    {
        Console.WriteLine("Camera");
    }

    public override void SendSMS()
    {
        Console.WriteLine("Sending SMS from Nokia 2700.");
    }
}

, , , .

+4

.

.

, . , .

,

public abstract class MyBase
{
    public abstract void MethodMustBeImplemented();
    public virtual void DoesNotHaveToBeOverwritten()
    {
      //Do WORk
    }
}


public class Implementor: MyBase
{

}

, MethodMustBeImplemented() .

public class Implementor: MyBase
{
    public override void MethodMustBeImplemented()
    {
      //Do WORk
    }
}
+2

:

[ ] [ ]. [ ] [it] , [ , ].

. , , . ( ) - .

- , ( , ..), , ( ). , . , , - Toshiba NX-42C?

+2

- , :

, , .

: : - ( ). Bec. , , [ ]

- : "abstract", ,

: call() sendSms() "abstract",

-

- , ,

+2

, , , .

.

, , ( , , ) .

, , , (, ) ( , ). , API.

+1
abstract class C{
public abstract void met1();
public void met2(){
    System.out.println("Hello");
}
}

bodyless , , , , Overridden .

, , Class C, met1 , met2 , , .

@Override
public void met2(){
    super.met2();
}

, SUBCLASS , SUPERCLASS.

:

Dog, , bark(), , , , , , BullDog, Dog.

+1

, , , , .

, , . , , . , , , , .

+1

Source: https://habr.com/ru/post/1542603/


All Articles