Abstract classes and static methods

I have an abstract report class AbstractReportClass which I am extending in multiple report classes (one for each report, say ReportA, ReportB, ...). Each report class has its own static column definitions, title, etc., which I have to access through a static method getDataMeta() in a web application. Each report has the same exact code in getDataMeta, and no report may exist without these fields. My intuition tells me that AbstractReportClass should contain the code for getDataMeta, but I know that you can't mix abstract and static keywords.
Am I missing a simple solution to unify the getDataMeta code in the abstract base class? or do I really need to have a static function getDataMeta with the same code in each of the base classes?
My apologies if this has been discussed many times before.
Thanks,
-Andrew

I'm not trying to be "right"; rather I just asked a question about whether I can do something that seems intuitive. Perhaps you might write code in a different way than I would or perhaps I wasn't clear about every little detail about my code? Do you regularly belittle people who ask questions here?
I have a loadFromDB() member function in AbstractReport for which all sub classes have an overloaded version. All reports I'm displaying have 4 common fields (a database id and a name and a monetary value, for example), but then each other report has additional fields it loads from the database. Inside ReportX classes' loadFromDB(), I call the superclass loadFromDB() function and augment values to get a completely loaded object. In fact, the loadedData member object resides in AbstractReport.
I can't use a report unless it has these common features. Every report is an AbstractReport. There is common functionality built on top of common objects. Isn't this the point of inheritance? I'm essentially saying that abstract class Shape has a getArea function and then I'm defining multiple types of Shapes (e.g. Rectangle and Circle) to work with...

Similar Messages

  • Nested Classes and Static Methods

    I was perusing the Java Tutorials on Nested Classes and I came across this...
    [http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html|http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]
    I was reading the documentation and I read a slightly confusing statement. I was hoping some further discussion could clarify the matter. The documentation on "Nested Classes" says (I highlighted the two statements, in bold, I am having trouble piecing together.)
    Static Nested Classes
    As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class ? it can use them only through an object reference.
    Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • Abstract class and static function

    Please tell me that why a static function can't be made abstract?
    Thanks.
    Edited by: RohitRawat on Sep 9, 2009 7:45 AM

    RohitRawat wrote:
    Please tell me that why a static function can't be made abstract?
    Thanks.Because the method belongs to the class.

  • Abstract class and a static method

    Can i call a static method within an abstract class ?

    public class AbstractDemo {
      public static void main(String[] args) {
        BiPlane biPlane = new BiPlane();
        System.out.println("biplane propulsion = " + biPlane.getPropulsionType());
        JumboJet jumboJet = new JumboJet();
        System.out.println("jet load = " + jumboJet.confirmMaxLoad());
        System.out.println("jet speed = " + jumboJet.getTopSpeed());
        System.out.println(Airplane.confirmMaxLoad());
    abstract class Airplane {
      static String confirmMaxLoad() {
        return "go_get_um, yeehaa!";
      public abstract String getPropulsionType();
      abstract String getTopSpeed();
    class BiPlane extends Airplane {
      public BiPlane() {
        System.out.println("BiPlane constructor");
      static String confirmMaxLoad() {
        return "400 lbs";
      public String getPropulsionType() {
        return "propeller";
      final String getTopSpeed() {
        return "130 knots";
    class JumboJet extends Airplane {
      public JumboJet() {
        System.out.println("JumboJet constructor");
      public String getPropulsionType() {
        return "jet";
      public String getTopSpeed() {
        return "mach .87";
    }

  • Why does this abstract class and method work without implement it?

    hi,
    I have seen many times that in some examples that there are objects made from abstract classes directly. However, in all books, manual and tutorials that I've read explain that we MUST implement those methods in a subclass.
    An example of what I'm saying is the example code here . In a few words that example makes Channels (java.nio.channel) and does operations with them. My problem is in the class to make this channels, because they used the ServerSockeChannel class and socket() method directly despite they are abstracts.
       // Create a new channel: if port == 0, FileChannel on /dev/tty, else
       // a SocketChannel from the first accept on the given port number
    private static ByteChannel newChannel (int netPort)
          throws Exception
          if (netPort == 0) {
             FileInputStream fis = new FileInputStream ("/dev/tty");
             return (fis.getChannel());
          } else {
    //CONFLICT LINES
             ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
             ssc.socket().bind (new InetSocketAddress (netPort)); //<--but here, this method (socket) is abstract. WHY RETURN A SOCKET????????  this mehod should be empty by default.
             System.out.print ("Waiting for connection on port "
                + netPort + "...");
             System.out.flush();
             ByteChannel channel = ssc.accept();
             ssc.close();
             System.out.println ("Got it");
             return (channel);
       } I test this code and works fine. So why can it be??
    Also, I read that the abstract classes can't have static methods. Is it true???
    Please Help!!
    PS: i have seen this kind of code many times. So i feel that I don't understand how its really the abstract methods are made.
    PS2: I understand that obviously you don't do something like this: *"obj = new AbstractClass(); "*. I dont understand how it could be: ServerSocketChannel ssc = ServerSocketChannel.open(); and the compiler didn't warn.

    molavec wrote:
    ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
    The static method creates an instance of a class which extends ServerSocketChannel, but is actually another non-abstract class.I thought that, but reading the documentation I saw that about open() method:
    Opens a server-socket channel.
    The new channel is created by invoking the openServerSocketChannel method of the system-wide default SelectorProvider object.
    The new channel's socket is initially unbound; it must be bound to a specific address via one of its socket's bind methods before connections can be accepted.
    ...and the problem is the same openServerSocketChannel is abstract, so i don't understand how it could return a ServerSocketChannel.There is a concrete implementation class that has implemented that method.
    I guess that really the open() method use a SelectorProvider's subclase but it doesn't appear in the doc.It doesn't need to. First, you don't care about those implementation details, and second, you know that if the class is abstract, it must use some concrete subclass.
    Ok, I speak Spanish by default (<-- this sounds like "I am a machine", ^_^' ). So, I didn't know how to say that the method would be {}. Is there a way to say that?? I recommendable for me to know, for the future questions o answers.Not sure what you're saying here. But the other respondent was trying to explain to you the difference between an abstract method and an empty method.
    // abstract method
    public abstract void foo();
    // empty method
    public void bar() {
    Which class does extend ServerSocketChannel? I can not see it.It may be a package-private class or a private nested class. There's no need to document that specific implementation, since you never need to use it directly.

  • ABSTRACT class and method

    Dear all Abaper experts,
    I am doubt on a abap object program shown as below. It is a ABSTRACT class and method. However, during compiling, an error message is displayed "The abstract method 'WRITE_STATUS' may not be implemented". What does it mean?
    REPORT  ZOOP_ABSTRACT.
    * Class Declaration
    CLASS vehicle DEFINITION ABSTRACT.
      PUBLIC SECTION.
        METHODS: accelerate,
                 write_status ABSTRACT.
      PROTECTED SECTION.
        DATA speed TYPE i.
    ENDCLASS.
    CLASS plane DEFINITION INHERITING FROM vehicle.
      PUBLIC SECTION.
        METHODS: rise.
      PROTECTED SECTION.
        DATA altitude TYPE i.
    ENDCLASS.
    CLASS ship DEFINITION INHERITING FROM vehicle.
    ENDCLASS.
    * Class Implementation
    CLASS vehicle IMPLEMENTATION.
      METHOD accelerate.
        speed = speed + 1.
      ENDMETHOD.
    ENDCLASS.
    CLASS plane IMPLEMENTATION.
      METHOD rise.
        altitude = altitude + 1.
      ENDMETHOD.
      METHOD write_status.
        WRITE: / 'Plane speed:', speed.
        WRITE: / 'Altitude:', altitude.
      ENDMETHOD.
    ENDCLASS.
    CLASS ship IMPLEMENTATION.
    ENDCLASS.
    * Global Data
    DATA: plane_ref TYPE REF TO plane,
          ship_ref  TYPE REF TO ship.
    * Classical Processing Blocks
    START-OF-SELECTION.
      CREATE OBJECT: plane_ref,
                     ship_ref.
      CALL METHOD: plane_ref->accelerate,
                   plane_ref->rise,
                   plane_ref->write_status,
                   plane_ref->accelerate,
                   plane_ref->write_status.
    All answers are welcome and appreciate for the help.

    Hi,
    try this code I've rearranged your Class Implementation and just added the foll code;
      write_status REDEFINITION in the Definition part of the Subclass.
    * Class Declaration
    CLASS vehicle DEFINITION ABSTRACT.
      PUBLIC SECTION.
        METHODS: accelerate,
                 write_status ABSTRACT.
      PROTECTED SECTION.
        DATA speed TYPE i.
    ENDCLASS.
    * Class Implementation
    CLASS vehicle IMPLEMENTATION.
      METHOD accelerate.
        speed = speed + 1.
      ENDMETHOD.
    ENDCLASS.
    CLASS plane DEFINITION INHERITING FROM vehicle.
      PUBLIC SECTION.
        METHODS: rise,
                 write_status redefinition.   
      PROTECTED SECTION.
        DATA altitude TYPE i.
    ENDCLASS.
    CLASS plane IMPLEMENTATION.
      METHOD rise.
        altitude = altitude + 1.
      ENDMETHOD.
      METHOD write_status.
        WRITE: / 'Plane speed:', speed.
        WRITE: / 'Altitude:', altitude.
      ENDMETHOD.
    ENDCLASS.
    CLASS ship DEFINITION INHERITING FROM vehicle.
      PUBLIC SECTION.
        METHODS: write_status redefinition. 
    ENDCLASS.
    CLASS ship IMPLEMENTATION.
      METHOD write_status.
        WRITE: / 'In Ship Class.'.
      ENDMETHOD.
    ENDCLASS.
    * Global Data
    DATA: plane_ref TYPE REF TO plane,
          ship_ref  TYPE REF TO ship.
    * Classical Processing Blocks
    START-OF-SELECTION.
      CREATE OBJECT: plane_ref,
                     ship_ref.
      CALL METHOD: plane_ref->accelerate,
                   plane_ref->rise,
                   plane_ref->write_status,
                   plane_ref->accelerate,
                   plane_ref->write_status,
                   ship_ref->write_status.
    Best Regards,
    Sunil.

  • Java abstract classes and methods

    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.

    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.

  • Question about Classes, Abstract  Classes and Interfaces.

    I have been experimenting with Classes, Abstract Classes and Interfaces and wonder if anyone can explain this to me.
    I was looking for a way to assign a value to a variable and then keep it fixed for the session and have devised this.
    First I create an abstract class like this:
    public abstract class DatabaseConnection {
    private static String ServerName = null;
    public static void setServerName(String serverName) {
              ServerName = serverName;
         public static String getServerName() {
              return ServerName;
    }and then I created an interface
    public interface DatabaseAccess {
         String servername = DatabaseConnection.getServerName();
    }And finally the class itself with some test lines in it so I could see what was going on:
    public class CreateDatabase extends DatabaseConnection implements DatabaseAccess {
         public static void main (String args[]){
              new CreateDatabase();
         public CreateDatabase(){     
              setServerName("Server Name 1");
              System.out.println ("Before update ");
              System.out.println ("ServerName from Interface           = " + servername);
              System.out.println ("ServerName from Abstract Class = " + getServerName());
              System.out.println ("After update ");
              setServerName("Server Name 2");
              System.out.println ("ServerName from Interface           = " + servername);
              System.out.println ("ServerName from Abstract Class = " + getServerName());
              System.out.println ("==========================");
    }The output I get from the above is:
    Before update
    ServerName from Interface           = Server Name 1
    ServerName from Abstract Class = Server Name 1
    After update
    ServerName from Interface           = Server Name 1
    ServerName from Abstract Class = Server Name 2
    ==========================I also tried this in another class which calls the above class to see if I get the same effect
    public class CheckDatabaseAccess {
         public static void main (String args[]){
              new CreateDatabase();
              CreateDatabase.setServerName("Server 3");
              System.out.println("CreateDatabase "+CreateDatabase.servername);
              CreateDatabase.setServerName("Server 4");
              System.out.println("CreateDatabase "+CreateDatabase.servername);
              CreateDatabase.setServerName("Server 5");
              System.out.println("CreateDatabase "+CreateDatabase.servername);
    }The output of which is this:
    Before update
    ServerName from Interface           = Server Name 1
    ServerName from Abstract Class = Server Name 1
    After update
    ServerName from Interface           = Server Name 1
    ServerName from Abstract Class = Server Name 2
    ==========================
    CreateDatabase Server Name 1
    CreateDatabase Server Name 1
    CreateDatabase Server Name 1Can anyone explain why I appear to only be able to change or set the ServerName only the once?
    Is this the correct way to do it? If it is it's exactly what I am looking for, a way to set the value of variable once in a session and then prevent it being changed.
    Or is there a better way of doing this.
    What I want to use this for is for example, storing the accesses to a database on a server. I won't know what server the database will be stored on nor what the database is called so I create an INI file which stores this information in encrypted format, which is set by the database administrator. It occurs to me I can use this method to then retrieve that data once and once only from the INI file and use that throughout the life of the session to access the database.
    Any help appreciated
    Regards
    John

    Not gonna read all of it, but this jumps out:
    public abstract class DatabaseConnection {
    private static String ServerName = null;
    public interface DatabaseAccess {
         String servername = DatabaseConnection.getServerName();
    }You have two completely separate variables (with two different names, for that matter, since you were inconsistent in your capitalization, but it wouldn't make a difference if they did have the same name with the same case). And the one in the interface is implicitly public, static, and final.
    Anytime you refer to "servername" through a reference of type DatabaseAccess, it refers to the one declared in the interface.
    Anytime you refer to "ServerName" inside the DatabaseConnection class, it refers to the one declared in that class.

  • What is the diff b/w Abstract class and an interface ?

    Hey
    I am always confused as with this issue : diff b/w Abstract class and an interface ?
    Which is more powerful in what situation.
    Regards
    Vinay

    Hi, Don't worry I am teach you
    Abstract class and Interface
    An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.
    Edited by SASIKUMARA
    SIT INNOVATIONS- Chennai
    Message was edited by:
    sasikumara
    Message was edited by:
    sasikumara

  • Difference between abstract class and the normal class

    Hi...........
    can anyone tell me use of abstract class instead of normal class
    The main doubt for me is...
    1.why we are defining the abstract method in a abstract class and then implementing that in to the normal class.instead of that we can straight way create and implement the method in normal class right...../

    Class vs. interface
    Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme. I use interfaces when I see that something in my design will change frequently.
    For example, the Strategy pattern lets you swap new algorithms and processes into your program without altering the objects that use them. A media player might know how to play CDs, MP3s, and wav files. Of course, you don't want to hardcode those playback algorithms into the player; that will make it difficult to add a new format like AVI. Furthermore, your code will be littered with useless case statements. And to add insult to injury, you will need to update those case statements each time you add a new algorithm. All in all, this is not a very object-oriented way to program.
    With the Strategy pattern, you can simply encapsulate the algorithm behind an object. If you do that, you can provide new media plug-ins at any time. Let's call the plug-in class MediaStrategy. That object would have one method: playStream(Stream s). So to add a new algorithm, we simply extend our algorithm class. Now, when the program encounters the new media type, it simply delegates the playing of the stream to our media strategy. Of course, you'll need some plumbing to properly instantiate the algorithm strategies you will need.
    This is an excellent place to use an interface. We've used the Strategy pattern, which clearly indicates a place in the design that will change. Thus, you should define the strategy as an interface. You should generally favor interfaces over inheritance when you want an object to have a certain type; in this case, MediaStrategy. Relying on inheritance for type identity is dangerous; it locks you into a particular inheritance hierarchy. Java doesn't allow multiple inheritance, so you can't extend something that gives you a useful implementation or more type identity.
    Interface vs. abstract class
    Choosing interfaces and abstract classes is not an either/or proposition. If you need to change your design, make it an interface. However, you may have abstract classes that provide some default behavior. Abstract classes are excellent candidates inside of application frameworks.
    Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class may provide default services such as event and message handling. Those services allow your application to plug in to your application framework. However, there is some application-specific functionality that only your application can perform. Such functionality might include startup and shutdown tasks, which are often application-dependent. So instead of trying to define that behavior itself, the abstract base class can declare abstract shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn't know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, Java calls the method defined by the child class.

  • When should I use abstract classes and when should I use interfaces?

    Can any body tell me in which scenario we use /we go for Interface and which scenario we go for abstract class, because as per my knowledge what ever thing we can do by using Interface that thing can also done through abstract class i mean to say that the
    behavior of the two class.
    And other thing i also want to know that which concept comes first into the programming abstract class or Interface.
    S.K Nayak

    The main differences between an abstract class and an interface:
    Abstract
    An abstract class can contain actual working code (default functionality), and can have either virtual or abstract method.
    An abstract class must be sub-classed and only the sub-classes can be instantiated. Abstract methods must be implemented in the sub-class. Virtual methods may be overridden in the sub-class (although virtual methods typically contain code, you still may
    need/want to override them). A good use for an abstract class is if you want to implement the majority of the functionality that a class will need, but individual sub-classes may need slightly different additional functioality.
    Interface
    An interface only contains the method signatures (method name and parameters), there is no code and it is not a class.
    An interface must be implemented by a class. An interface is not a class and so it cannot be sub-classed. It can only be implemented by a class. When a class implements an interface, it must have code in it for each method in the interface's definition.
    I have a blog post about interfaces:
    http://geek-goddess-bonnie.blogspot.com/2010/06/program-to-interface.html
    (sorry, I have no blog posts specific to abstract classes)
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • Abstract class and RMI

    Hi!
    I have a desgin where I have an abstract class that in its constructor registers itself in a registry and define three abstract methods. Then I have a class that extends the abstract class and implements the three methods.
    One of the methods inserts som text in a textArea defined in the child of the abstract class but when I call this method remotly I get a nullpointer exception saying that the textArea has not been initialized. The child ofcause calls super in its constructor.
    So my question is can you not extend an abstract class that register it self in the constructor and then call methods remotly that uses variables that have been initialized in a childs constructor?
    Have your any idea to why I get the nullpointer exception?
    Peter

    >
    This sounds like there might be a misunderstanding
    about the nature of methods and variables. If, for
    instance, your client looks something like this:
    RObject roo = ...// get via RMI
    TextArea text = roo.getTextArea();
    text.setText("...");
    My design is more like this:
    public interface Subscriber extends Remote {
      public void notifySubscriber();
    public abstract class A implements Subscriber {
      a() {
        server.addSubscriber(this);
      public abstract method1();
      // some more abstract methods
      public void notifySubscriber() {
        // do some stuff
        method1();
    public class B extends A {
      JTextArea text;
      A() {
        super();
        text = new JTextArea();
      public void method1() {
        // do some stuff
        // then text is null when called remotly
        text.setText("Hello");
    }Hope this makes my design more clear and you can see the problem.
    Thanks in advance

  • Question about abstract classes and instances

    I have just read about abstract classes and have learned that they cannot be instantiated.
    I am doing some exercises and have done a class named "Person" and an abstract class named "Animal".
    I want to create a method in "Person" that makes it possible to set more animals to Person objects.
    So I wrote this method in class Person and compiled it and did not get any errors, but will this work later when I run the main-method?
    public void addAnimal(Animal newAnimal)
         animal.add(newAnimal);
    }Is newAnimal not an instance?

    Roxxor wrote:
    Ok, but why is it necessary with constructors in abstract classes if we don�t use them (because what I have understand, constructors are used to create objects)?Constructors don't create objects. The new operator creates objects. An object's c'tor is invoked after the object has already been created. The c'tors job is to initialize the newly-created object to a valid state. Whenever a child object is created, the parent's c'tor is run before the child's c'tor, so that by the time we're inside the child's c'tor, setting up the child's state, we know that the parent (or rather the "parent part" of the object we're initializing) is in a valid state.
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Abstract classes and OO theory...

    I have an OO theory question related to abstract classes and their member variables. I realize opinions will vary from person to person but I'll ask anyway...
    If I'm creating an abstract class, should member variables that will be used by subclasses be private or protected? Why? Either way, they will have accessor methods for classes that instantiate them (where appropriate) but I'm debating whether or not to give subclasses direct access to these variables or not.
    To me, it seems odd to make variables in the abstract class private but I'm curious what your opinions are.
    Thanks...

    I knew you'd say that. I'd like to play along with a for-instance, if you will allow ... here's an example parent class:
    public abstract class ProvideMenu   extends JFrame {
      protected              JMenuBar       jmbar;
      protected              JMenu          jmfile,
                                            jmedit,
                                            jmhelp;
      protected              JMenuItem      jmfnew,
                                            jmfopen,
                                            jmfsave,
                                            jmfsaveas,
                                            jmfprint,
                                            jmfexit,
                                            jmecopy,
                                            jmepaste,
                                            jmhabout,
                                            jmhcontents;
      public ProvideMenu() {
        jmbar       = new JMenuBar();
        jmfile      = new JMenu( FILE_MENU );
        jmedit      = new JMenu( EDIT_MENU );
      public abstract void aMeth();
    }Now the subclass does not need to provide setProvideMenuFont( new Font( ... ) ) and Font getProvideMenuFont() methods, setProvideMenuEnabled(), etc. but can use the standard methods setFont, getFont setBackground(), setEnabled, etc, etc.
    Mind you I'm not advocating this ... what I am doing is trying to open the discussion up a bit - I hope no one minds ... what better design - just a for-instance - would you advocate?
    ~Bill

  • Abstract class and class

    What is the difference between abstract class and class in java?

    arcadesstuff wrote:
    Abstract class: a class that contains at least one abstract method. As has already been mentioned, abstract classes need not contain any methods at all. Have a look at the abstract class you posted; it's still abstract, though it contains no abstract methods. Note that if one declares any method of a class abstract, the class itself must be declared abstract as well.
    When you implement the abstract class Animal, you will have to write the code of those two abstract methods from above.Your example contains no abstract methods. Abstract methods must be marked with the keyword "abstract".
    ~

Maybe you are looking for

  • Can't send email from Outlook with parentheses in address

    I can't send email from Outlook 2007 through my WRT400N when Outlook displays the address with parentheses as in this example: Firstname Lastname ([email protected]) I can send if the address is in this form: Firstname Lastname <[email protected]> I

  • Latest Creative Cloud install stopped by Adobe Application Manager. Error message 82 says to close AAM. I don't know how to do that.

    While trying to download the latest issue of Creative Cloud Error message 82 says Adobe Application Manager has to be closed first, which I can't figure out to do. Can anyone help me with this? Thanks. Rich

  • Firefox sporadically moves my current tab to a new window.

    About 2-3 times per week, I'll be browsing with multiple tabs open, and Firefox will suddenly "close" my current tab and re-open it in a new window. I say "close" because the tab is not listed under "Recently Closed Tabs." Rather, Firefox seems to ju

  • Was Thread Deleted

    Hi. I made a thread yesterday that had a title Out Of Topic yesterday that was asking on how to format posts to take URL's that may have spun out of control into a runaway thread. What happened to it? I got like 2000 email notifications that the thre

  • I have aproblem please help me

    i use developer 10g suite2 and when i use form builder and run the form it give me this message ORA-12560: TNS:protocol adapter error i am a student and i have a single pc in my home i start OC4J but it does not work please tell me why it deos not wo