4 Replies Latest reply: Nov 19, 2008 10:11 AM by 843785 RSS

    Java abstract classes and methods

    843785
      Can anyone please tell me any real time example of abstract classes and methods.
      I want to know its real use. If anyone have ever used it for some purpose while programming please do tell me.
        • 1. Re: Java abstract classes and methods
          843785
          java.util.AbstractList

          And "real time" does not mean what you think it does: [Real-time computing|http://en.wikipedia.org/wiki/Real-time_computing].

          What you wanted where probably "real world examples", i.e. examples that exist in the real world as opposed to just text book examples.
          • 2. Re: Java abstract classes and methods
            843785
            No please.. I just want to know if you have used it while programming. Like "an abstract class can be used to put all the common method names in it without having to write actual implementation code."

            I want to know its usage in programming, not just a definition. I guess you understand what I am looking for.
            • 3. Re: Java abstract classes and methods
              843785
              Ashu_Web wrote:
              No please.. I just want to know if you have used it while programming. Like "an abstract class can be used to put all the common method names in it without having to write actual implementation code."
              That would describe an Interface better than an abstract class. Abstract classes usually have at least some implementation.
              I want to know its usage in programming, not just a definition. I guess you understand what I am looking for.
              Yes, and I gave you one: java.util.AbstractList. It can be found inside the src.zip in your JDK directory and it is a pretty good example for an abstract class that provides some implementation and defines exactly what is necessary to make a full List implementation.
              • 4. Re: Java abstract classes and methods
                843785
                Additionally, the basic idea is that you don't want folks to use the class asis - for any of many reasons. You want the actual implementation left up to those closer to the usage.