Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:20:06+00:00 2026-05-15T19:20:06+00:00

In the following example, the class Derived implements the abstract method method from class

  • 0

In the following example, the class Derived implements the abstract method method from class Main. But I can’t think of a reason to fill in the method body in the abstract Derived class’ implementation. Surely I should only implement abstract methods within real classes.

So how can I avoid doing it? What else can I do?

abstract class Main
{
    public abstract void method();
}
abstract class Derived : Main
{
    public override void method()
    { 
    }
}

class RealClass : Derived
{

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:20:07+00:00Added an answer on May 15, 2026 at 7:20 pm

    Usually if someone has specified that an abstract class has an abstract method, it’s either because that class depends on that method for some of what it does, or it’s because it’s part of an expected API that it wouldn’t make sense for the parent class to implement at this time. In either case, there must be an implementation once you get to a non-abstract implementation of the class.

    Note also that if you are implementing an interface, you are required to state how that interface will be implemented, even if you just call the member abstract and pass the responsibility onto the subclass

    public interface IPet {string GetNoise(); int CountLegs(); void Walk();}
    public abstract class Pet : IPet
    {
        public string Name {get; set;}
        public abstract string GetNoise(); // These must be here
        public abstract int CountLegs();
        public abstract void Walk();
    }
    

    When it comes to implementing the sub-class, you have a few choices depending on the circumstances. If your implementation is itself an abstract class, you shouldn’t need to implement the abstract method.

    public abstract class Quadruped : Pet
    {
        public override int CountLegs () { return 4; }
    }
    

    If your implementation is non-abstract, but the standard reason for the method in question really doesn’t apply in your circumstance, you can do a no-op method (in the case of void methods), or return some dummy value, or even throw a NotImplementedException to indicate that the method should never have been called in the first place.

    public class Fish : Pet
    {
        public override string GetNoise() {return "";} // dummy value: fish don't make noise
        public override int CountLegs() {return 0;}
        public override void Walk() {} // No-op
        // public override void Walk() { throw new NotImplementedException("Fish can't walk"); }
    }
    

    Does that answer your question?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer sqlite3 (or any other good relational DB, but sqlite comes… May 16, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer I hadn't heard of the syntax prior to this, but… May 16, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer <form> is valid inside a <td> element. You can check… May 16, 2026 at 3:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Consider the following example. I have an interface MyInterface, and then two abstract classes
Given the following code: public interface IExample { ... } public abstract class BaseExample:
Given an abstract interface and an implementation derived from that interface, where constructors are
Consider the following simple example: [DataContract({0}Base)] public class Base<T> where T : Entity<T> {
I have the following classes (trimmed to only show the basic structure): public abstract
greetings. i have the following class: public class Ship { public enum ValidShips {
Given the following template: template<class T> class Container { private: boost::function<T> f; }; ...
The following example, beats me. I've been so far thinking, that when functor is
I have the following class which I'm fighting over how to implement. The question
Library at http://testapi.codeplex.com/ Excerpt of usage from http://blogs.msdn.com/ivo_manolov/archive/2008/12/17/9230331.aspx A third common approach is forming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.