Abstract class extending a nonabstract

i want to know what are the effects , advantages and cases were we want to use this cinda achitecture.
I have a class(NA) which is NonAbstract, There is a Abstract class(A) which extends a NA. Doing so is legally right, but what are the advantages of doing that are there any situations were we will be using this technique.
TIA
Zoha.

Every abstract class extends a non-abstract class already: Object is non-abstract, and since all abstract classes directly or indirectly extend Object... see?
So if you can see the reason for abstract classes at all, then you don't need to ask this question.

Similar Messages

  • Abstract class extends other class?

    What happens when a abstract class extends other class?
    How can we use the abstract class late in other class?
    Why do we need an abstract class that extends other class?
    for example:-
    public abstract class ABC extends EFG {
    public class EFG{
    private String name="";
    private int rollno="";
    private void setName(int name)
    this.name=name;
    private String getName()
    return this.name;
    }

    shafiur wrote:
    What happens when a abstract class extends other class?Nothing special. You have defined an abstract class.
    How can we use the abstract class late in other class?Define "Late". What "other class"?
    Why do we need an abstract class that extends other class?Because it can be useful to define one.

  • Can an abstract class extend another abstract class?

    Is it possible for an abstract class to extend another abstract class?
    Say
    public abstract class AComponent extends JComponent {
    Thanks.

    Yes

  • Extend abstract class & implement interface, different return type methods

    abstract class X
    public abstract String method();
    interface Y
    public void method();
    class Z extends X implements Y
      // Compiler error, If I don't implement both methods
      // If I implement only one method, compiler error is thrown for not
      // implementing another method
      // If I implement both the methods,duplicate method error is thrown by 
      //compiler
    The same problem can occur if both methods throw different checked exceptions,or if access modifiers are different..etc
    I'm preparing for SCJP, So just had this weired thought. Please let me know
    if there is a way to solve this.

    Nothing you can do about it except for changing the design.
    Kaj

  • @Override when extending an abstract class

    Hi!
    I have an abstract class A with one abstract method B. I then created a class C which extended A. Eclipse then automatically created the abstract method. But it also added @Override.
    Like this:
    @Override
    protected void B()
         // something
    }What does the @Override do?

    http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html

  • Extending Abstract Classes & Program Entry Point

    I have the following classes:
    CopServlet - which extends PercServlet
    PercServlet - abstract class which extends HttpServlet
    HttpServlet is the base class. I'm using Visual Age with a web.xml file that points to CopSerlet as the controller servlet. So my question is... When CopServlet gets called, where is my program entry point? My CopServlet class does NOT have a main method.

    When CopServlet gets loaded, its init() method is called. And when it is called via an HTTP request, either its doGet() or its doPost() method is called, depending on whether it was a GET or a POST request. That's how servlets work. The business about abstract classes is irrelevant to that.

  • Using the UI editor  for a class that extends an abstract class

    Hi,
    At the moment it's unfortunately impossible to use the UI editor to edit a class that extends a certain abstract class. There is a way to circumvent this problem, by using a proxy class. Does anyone know how to create a proxy class for this purpose and how to register it?
    Hopefully a future JDeveloper release will solve this problem. Is this a planned feature?
    Regards,
    Peter

    I hope it works for you now (why using , but not indentation?).                                                                                                                                                                                           

  • Abstract classes and extend

    hello
    -1 if i have a abstract class
    2-then i extend it in three deferent classes
    3-then i have put them in vector
    hassan[i ]
    4-then i have overload function in all three class (move)
    5- when i try to call this method (hassan.move ) by index
    how compiler work with this reference that are deferent but have function with same name
    friend told me compiler does not compile this line and write as it is.
    and at run time it will be compiled .---------is that correct?

    The method invocations are stored by name and argument types in the class file. They are resolved at run time anyway whether the static (compile-time) variable type is an abstract class or not.

  • Extending abstract classes

    I just have a simple question. I have one class which is abstract
    public abstract class Person
         private String firstName;
         private String lastName;
         private String title;
         private String dateOfBirth;
         private String homeAddress;
         private String phoneNumber;
         public static final String MR = "Mr";
         public static final String MISS = "Miss";
         public static final String MS = "Ms";
         public static final String MRS = "Mrs";
         public static final String DR = "DR";
         public static final String PROF = "Prof";
         public Person(String firstName, String lastName, String title, String dateOfBirth,
                         String homeAddress, String phoneNumber){
              this.firstName=firstName;
              this.lastName=lastName;
              this.title=title;
              this.dateOfBirth=dateOfBirth;
              this.homeAddress=homeAddress;
              this.phoneNumber=phoneNumber;
         And i have another class which extends this class
    public abstract class Borrower extends Person{
      public LibraryItem [] itemsBorrowed;
      private double currentFine;
      private int barCode;
      public LibraryItem [] getItemsBorrowed()
           return itemsBorrowed;
      public double getCurrentFine()
           return currentFine;
      public int getBarCode()
           return barCode;
      }When i try to compile these two classes, i get the error
    Cannot find symbal constructor Person(). The problem is that the tutor hates us providing default constructors, and i presume that this is what the error is asking for. Is there any way around this or does a default constructor need to be povided?
    cheers

    codingMonkey wrote:
    georgemc wrote:
    nick2price wrote:
    Ok, i get you, better call the superclass constructor as tutor hates me using no param constructorsChallenge him on that. Not only are they perfectly acceptable, they're a mandatory part of the JavaBeans spec.Personally, even though there are nothing wrong with them, I prefer to avoid no-arg constructors in a lot of cases. Usually when I feel that a class should always have certain attributes. I.e. instead of having a no-arg constructor for something like a Person class, I'd rather have a constructor that takes at least a name. It is true that the name could always be initialized in the no-arg constructor, but I would think that it makes more sense for a person to always have a name, rather than being called "null" or "N/A".If you plan on using any framework that uses the Beans spec (and while the inexperienced, self-professed "purist" might balk at that, you'll find it virtually impossible to avoid as a commercial coder) you won't be able to with those classes. Your argument about always needing a sensible starting point falls down where you have multiple disparate types that you are re-constructing. While it's quite nice to say "a Person should always have a Name", if you have, for example, a persistence framework that will generically map the results of various database queries back onto Java objects, you have to write some special case code for each class in your domain model, that says "in order to contruct this object, you first need to perform this query, then invoke this constructor with this part of the result of that query, then populate the rest of the properties using setter methods". For every class in your domain model. That's a fair amount of overhead. The no-args constructor model completely circumvents that, since everything's populated by the same generic code - beans introspection. Think about it. For every class in your model, you have to have separate chunks of code that are aware of - and hence, coupled to - a specific query, and a specific constructor of a specific class. Far from ideal.
    Even if you decide to roll your own code to manage peristence, configuration, remoting and the like, you'll still eventually settle on no-args constructors as extremely handy tools. Note that I'm all for the presence of other constructors as well, that do allow sensible creation of objects with certain values. Just that the no-args constructor is so infinitely useful for writing a huge amount of generic code
    I would think that it makes more sense for a person to always have a name, rather than being called "null" or "N/A".Me too. And there's nothing in any of my points that gainsays, or opposes that. You create a Person instance, and he's called "null" for a few clock cycles before you populate him from a database query - nothing wrong with that

  • Extending abstract classes such as ByteBuffer?

    How would I extend an abstract class such as ByteBuffer?
    If I call the normal extends key word:
    public class MyBuffer extends ByteBuffer
    then I need to implement virtually every method in the class.
    But If I just create a ByteBuffer such as:
    ByteBuffer buf = BtyeBuffer.Allocate(100);
    then I can just go and use all of the various methods witin the class without have to implement anything.
    But I need to add an additional method to ByteBuffer . What is the best way to do this? I realize I can encapsulate a ByteBuffer object but that does not sound like a good idea.
    Is there a better way? If so what?

    Thanks. Well that gets me started.
    I have:
    public abstract class SerialPortBuffer extends ByteBuffer {
    and I am getting:
    Implicit super constructor ByteBuffer() is undefined for default constructor. Must define an explicit constructor     
    How do I fix this? Sorry for the newbie questions.

  • Extending Abstract Classes such I ByteBuffer?

    Sorry for the cross post but I think I posted this in the wrong forum origanally.
    I need to extend ByteBuffer so I did so like this:
    public abstract class SerialPortBuffer extends ByteBuffer {
    but now I am getting:
    Implicit super constructor ByteBuffer() is undefined for default constructor. Must define an explicit constructor
    How do I fix this? Sorry for the newbie questions and the goof on the cross post.

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    But I dodnot think defining a no args constructor explicitly would remove the problem, since the no args constructor is still undefined in the super class. You need to define a constructor woth some arguments
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    public abstract class SerialPortBuffer extends ByteBuffer {
         * @param arg0
         * @param arg1
         * @param arg2
         * @param arg3
         SerialPortBuffer(int arg0, int arg1, int arg2, int arg3) {
              super(arg0, arg1, arg2, arg3);
              // TODO Auto-generated constructor stub
    When I try this I get.
    The constructor ByteBuffer(int, int, int, int) is not visibe
    Can anyone tell me how to extend ByteBuffer?

  • Can interface extend abstract class?

    Can interface extend abstract class?
    I tried to make a interface extend an abstract class but i got an error stating:
    interface expected here.
    Can anyone help me ?

    > ok, but can an interface implement an abstract class?
    No. An interface provides no implementation whatsoever. An abstract class can implement an interface, but not the other way around.
    http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
    ~

  • Why Immediate and ultimate super class extends in one abstract class ?

    What�s a need to extents the two super class in single class
    public abstract class ProcessorServlet extends HttpServlet implements Servlet

    What�s a need to extents the two super class in
    single class
    public abstract class ProcessorServlet extends
    HttpServlet implements Servlet
    Only one class is being extended. HttpServlet.
    Servlet is an interface.
    You may only extend ONE class. You may implement as many interfaces as you like (there is probably some limit but not worth worrying about).

  • Abstract class with set and get methods

    hi
    how to write set and get methods(plain methods) in an abstartc class
    ex: setUsername(String)
    String getUsername()
    and one class is extending this abstract class and same methods existing in that sub class also..... how to write......plz provide some ideas
    am new to programming....
    asap
    thnx in advance

    yes... as i told u.... i am new to coding......
    and my problem is ..... i have 2 classes one is abstract class without abstract methods.. and another class is extending abstract class.....
    in abstract class i have 2 methods...one is setusername(string) and getusername() ..... how to write these two methods.... in abstract class i have private variables username...... when user logins ..... i need to catch the user name and i need to validate with my oracle database and i need to identify the role of that user and based on role of that user i need to direct him to appropriate jsp page.......
    for that now i am writing business process classes..... the above mentioned two classes are from business process.....
    could u help me now
    thnx in advance

  • Calling a super.ssuper.method but your super is a abstract class.

    Dear guys,
    Is that possible to invoke your super's super's method but your super is a abstract class?
    like:
    class GO {   public void draw() { } }
    abstract class GORunner extends GO {}
    class GOCounter extends GORunner {
    public void draw() {
    super.super.draw();
    I want to do this because I would like to take advantages of the abstract as an layer to achieve some polymorphism programming Therefore, in the later stage of the programming some code may only refer to GORunner but actually it is holding a GOCounter object.
    Thank!!

    BTW you don't need to write this
    public void draw() {
       super.draw();
    }It works but its basically the same as not having it at all.

Maybe you are looking for

  • Ipod not working, doesn't show up in source panel

    i'm trying to restore my non-working ipod in itunes, but its not even showing up in the source panel when i connect it via usb. can i assume this means it's hopeless and i should just get a new one?

  • "INVALID_DYNPRONAME" runtime error

    Hai all! i am trying 2 implement a selection screen with two paramerers , purchasing organization & plant.. i want 2 get f4 help for plant based upon the value of purchasing organization tht v will give at runtime.. but while running my program i am

  • Go to next song not working itunes 11

    Most puzzled by the fact that when using the most "game-changing" feature of Itunes 11, the new album view, that it ill not automatically move to the next song; instead you have to press <command> L for each song. Odd that it will move in song view,

  • How to view iPhoto journal in iCloud

    Has anyone figured out how to identify the URL to view the "Home Page" in iCloud for journals created by iOS iPhoto?

  • Cluster resource SID.WORLD' (resource type '', DLL 'fsresodbs.dll') either crashed or deadlocked.

    Dear Friends, We are facing issue with our systems which is running on win2008 with oracle DB this is MSCS environment. Automatically some resource moved to node2 from node1 and database went down, in fail safe cluster management i can see error as b