none
Where the virtual method and override method belong to in object oriented programming concept? RRS feed

  • Question

  • The virtual method is overridden from override method.

    I don't know where these belong to in the object oriented programming concept?

    Do the virtual/override belong to polymorphism or abstraction?

    Sunday, March 29, 2020 5:18 AM

Answers

  • Hi Jeff,

    Also, note that these virtual methods do not have to be only in an abstract class. You can make any method virtual in any type of class.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:38 AM
    Sunday, March 29, 2020 5:52 PM
    Moderator
  • The virtual method is overridden from override method.

    I don't know where these belong to in the object oriented programming concept?

    You can use it in an base abstract class. An base abstract class is a blue-print class specifying what methods are expected in a class that is derived from the base abstract class that should be implemented.

    The base abstract class has unimplemented methods that are overridable. An overridable unimplemented method in an base abstract class allows the developer to override the overridable unimplemented method in the derived class and implement code in the method in the derived class. 

    Do the virtual/override belong to polymorphism or abstraction?polymorphism

    Poly becuase the derived class is taking another form with its implemented methods.

    Abstraction is an abstract class.

    • Proposed as answer by Naomi NModerator Sunday, March 29, 2020 5:55 PM
    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:37 AM
    Sunday, March 29, 2020 7:38 AM
  • It is polymorphism as the virtual method has a new form or behavior by overriding in the derived class.

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Blog | LinkedIn | Stack Overflow | Facebook
    profile for Ehsan Sajjad on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by DA924x Sunday, March 29, 2020 7:25 PM
    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:37 AM
    Sunday, March 29, 2020 5:02 PM

All replies

  • The virtual method is overridden from override method.

    I don't know where these belong to in the object oriented programming concept?

    You can use it in an base abstract class. An base abstract class is a blue-print class specifying what methods are expected in a class that is derived from the base abstract class that should be implemented.

    The base abstract class has unimplemented methods that are overridable. An overridable unimplemented method in an base abstract class allows the developer to override the overridable unimplemented method in the derived class and implement code in the method in the derived class. 

    Do the virtual/override belong to polymorphism or abstraction?polymorphism

    Poly becuase the derived class is taking another form with its implemented methods.

    Abstraction is an abstract class.

    • Proposed as answer by Naomi NModerator Sunday, March 29, 2020 5:55 PM
    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:37 AM
    Sunday, March 29, 2020 7:38 AM
  • It is polymorphism as the virtual method has a new form or behavior by overriding in the derived class.

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Blog | LinkedIn | Stack Overflow | Facebook
    profile for Ehsan Sajjad on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by DA924x Sunday, March 29, 2020 7:25 PM
    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:37 AM
    Sunday, March 29, 2020 5:02 PM
  • Hi Jeff,

    Also, note that these virtual methods do not have to be only in an abstract class. You can make any method virtual in any type of class.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by Jeff0803 Monday, March 30, 2020 3:38 AM
    Sunday, March 29, 2020 5:52 PM
    Moderator
  • Yes I told that the virtual/override belong to the polymorphism from the interview but my interviewer insisted that it is not the polymorphism but abstraction in OOP.

    Monday, March 30, 2020 3:37 AM
  • they were probably confusing you by conflicting with your answer, it is polymorphism not abstraction.

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Blog | LinkedIn | Stack Overflow | Facebook
    profile for Ehsan Sajjad on Stack Exchange, a network of free, community-driven Q&A sites


    Monday, March 30, 2020 4:57 AM
  • Yes I told that the virtual/override belong to the polymorphism from the interview but my interviewer insisted that it is not the polymorphism but abstraction in OOP.

    Yeah I had a jackass interviewer do something similar with the 'using' that has two functionalities in c# with one usage for namespaces at the top of the class,  and the other usage was for a 'using' in object instancing. 

    That jackass didn't know that!

    Monday, March 30, 2020 6:08 AM