• RELEVANCY SCORE 5.02

    DB:5.02:Abstract Class Doubt ?? 7k




    what's the difference between the first abstract class and second abstract class .. when and where to use the first type and second type .. Please give me some info on it ...

    First Abstract Class
    public abstract class TestT where T : class
    {

    }

    Second Abstract Class

    public abstract class Test
    {

    }Regards, Gullu.

    DB:5.02:Abstract Class Doubt ?? 7k

    The second class is just a general abstract class - class that cannot be instantiated and is meant to provide common definition of a base class that multiple derived classes can share.
    More about abstract classes on MSDN.
    The first one is a generic abstract class that uses constraints to place requirements on the generic parameter (T). In your case the generic parameter can only be a type that match or inherit from specific base (you call this type 'class').
    e.g.

    public class Testable
    {

    public void Test()
    {
    //some logic here
    }

    }

    public abstract class TestT where T : Testable
    {
    public T t1;

    public void DoWork()
    {
    t1.Test(); //this will work because T must be of type Testable
    }
    }

    More about constraints on MSDN.

  • RELEVANCY SCORE 4.74

    DB:4.74:Doubt About Incomplete Keyword In Abstract Class a7




    Hai,
    I have a doubt about the usage of "incomplete" keyword in abstract class.will any body explain me the same ?
    Also is there any way not to override an abstract method defined in an abstract class, in a class extending the abstract class ?
    Thanks in advance

    DB:4.74:Doubt About Incomplete Keyword In Abstract Class a7

    I have a doubt about the usage of "incomplete"
    mplete" keyword in abstract class.will any body
    explain me the same ?There is no such keyword.

    Also is there any way not to override an
    erride an abstract method defined in an abstract
    class, in a class extending the abstract class ?Yes, by declaring the subclass as abstract.

  • RELEVANCY SCORE 4.70

    DB:4.70:Abstract Class Information. c3




    Hi All,

    I have a doubt. I have created a entity object class which extends the OAEntityImpl class. Now when I rebuild my project the error I get is , the class I declared is not a abstract class and it does not define one of the method from OAEntityImpl class.

    My problem is , can I declare my class as abstract or do I have to implement all the methods from OAEntityImpl class.

    My problem with the application is solved though. Just for information I want to know what is the possible solution.

    Regards
    Jhansi

    DB:4.70:Abstract Class Information. c3

    Thanks, I got it working.

    Regards
    Jhansi.

  • RELEVANCY SCORE 4.64

    DB:4.64:Abstract Class 8s


    What does it mean to declare a class as abstract?

    DB:4.64:Abstract Class 8s

    If you have at least one abstract method in your
    class, that class must be abstract.

    If you implement any interface and you dont override
    all methods of that interface, your class must be
    declared abstract.

    If you extend an abstract class and you dont override
    all abstract methods of the parent class, your class
    must be declared abstract.

    Abstract generally is used to create an specific
    behavior available to all subclasses. And each
    subclass must override that abstract method in such a
    specific behavior.

    I think thats it.There's one more situation. It's when you declare a fully concrete class to be abstract. It's useful when you want a class to act as superclass but you want to supply a default implementation to all methods. Subclasses only have to override what they want to change.

  • RELEVANCY SCORE 4.49

    DB:4.49:Abstract Method And Class x3


    I'm a beginner in Java and just learn about abstract method and class.
    However, i am wondering what is the point of using abstract method/class?
    Because when I delete the abstract method and change the class name to public class XXXX( changed from "abstract class XXXX), my program still runs well, nothing goes different.
    Is it because I haven't encountered any situation that abstract method is necessary or ?

    Thanks!

    DB:4.49:Abstract Method And Class x3

    excellent explanation jverd....I was struggling with this issue too- the way my book explains it was not clear....thanks!!!!

  • RELEVANCY SCORE 4.26

    DB:4.26:All The Methods Inside An Abstract Class Should Be Abstract Or Both Abstract And Non Abstaract? ck


    All the Methods inside an abstract class should be abstract or both abstract and non abstaract?

    T prabhakara Rao

    DB:4.26:All The Methods Inside An Abstract Class Should Be Abstract Or Both Abstract And Non Abstaract? ck

    Hi Prabhakara,
    Concrete class is nothing but normal class, we can use as a base class or may not.Not compulsory, it can't contain abstract methods.we can create object and work with this class.

    class Sample
    {
    public void MyMethod()
    {..............
    }
    }

    Abstract class:- Abstract class is class which declared with a keyword Abstract,
    Must be used as a base class.Only intension to declare a abstract class is to use as a base class,that is we can't create object of this class like concrete class.It can contain abstract methods as well as concrete(normal) methods.

    public abstract class MyClass
    {
    public void MyMethod()
    {..............}

    public abstract TestMethod()
    {
    . ........
    }
    }PS.Shakeer Hussain

  • RELEVANCY SCORE 4.22

    DB:4.22:Factory Pattern And Interface d3


    I have Created an interface named as[b] IaddressDetailsDao class
    whcich has so many methods I am implenting partialy by declaring it as
    abstarct class.whcich has the method signature as below________________

    public abstract IaddressDetailsDao get AddressDetails();

    My doubt is what will be the return type of this method

    DB:4.22:Factory Pattern And Interface d3

    If you have a profusion of methods within an interface or class, consider refactoring the single interface into multiple, smaller ones.

    That having been said, you are creating an interface for a DAO, correct? So, if you have a method within the DAO called 'getAddressDetails()', my assumption would be that the DAO would return an instance of 'address details'. Assuming you are programming to interfaces (a good thing), you would see something like:

    interface IAddressDetails {
    // spiffy domain model methods go here
    }

    interface IAddressDetailsDao {

    abstarct public IAddressDetails getAddressDetails(final int pk);
    }- Saish

  • RELEVANCY SCORE 4.14

    DB:4.14:Constructor In An Abstract Class xj



    Can we have a constructor in an Abstract class??

    DB:4.14:Constructor In An Abstract Class xj


    You can't instantiate an abstract class but you can have a constructor. It is only ever called, however, when instantiating an object of a subclass. ( Indeed, it MUST be called in the most recent releases ).

  • RELEVANCY SCORE 4.14

    DB:4.14:Httpservlet Class In Abstract Class 8z


    HttpServlet class is an abstract class. but we dont override all the methods why?

    DB:4.14:Httpservlet Class In Abstract Class 8z

    Perhaps it was designed so that vendors can inherit and add additional functionality but of course, Sun implemented the fundamental logic to support the HTTP standards

  • RELEVANCY SCORE 4.03

    DB:4.03:Abstract Class 3s


    C# Abstract- Why we use Abstract Class?
    Details:

    Pros ????????Cons ???????

    DB:4.03:Abstract Class 3s

    In thier Core both Abstract Classes and Interfaces have similiarties:
    They cannot be instantiated, but can be used as variables (so anything that inherits/implements them can be feed to a function). Both allow defining wich functions all inheritors/implementers have to code out. Both allow to define Varriables the resulting
    class will have (Interfaces via properties, AC via variables or Properties).

    The only difference is that abstract classes are classes. A class can only inherit a single class, but inherit infinite amounts of interfacces. Designers choose AC when the classes functionality are the main purpose of whatever will code it out.

    IComparable allows comparing. No mater where you implement it, Comparability is only a small, unimportant part of the class. A minor feature.
    DBConnection is an abstract class. No mater what you derive from it, being a Db Conenction is it's main purpose. It cannot also be a window, a button, or some other class. Wich is very important, as DBConnections have to be used and recycled as fast as possible
    (in case you forgot to dispose of it).

    Generally, you do not need to write abstract classes. 95% of all times you ask yourself, Interfaces are the right answer. Unless you write some class library or need to write a common baseclass for your own little class heirarchy, you will not need abstract
    classes.Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2

  • RELEVANCY SCORE 3.82

    DB:3.82:Why Are We Using Abstract Class? pp


    Why are we using Abstract class? What is specify use of Abstract class?

    DB:3.82:Why Are We Using Abstract Class? pp

    Thx for the lessons....that may help with an upcoming homework assignment.

  • RELEVANCY SCORE 3.77

    DB:3.77:Abstract Class Private Instance Method cd


    Hi!
    I'd like to know if there is any trick to invoke abstract class private instance method?
     
    // abstract class
    using System;
    abstract class MainClass{    string instanceMethod()      {               return instanceMethod() in abstract MainClass;    }
        static string staticMethod()     {        return staticMethod() in abstract MainClass;     }
        static void Main()    {        // Console.WriteLine(instanceMethod()); // ?                                                               Console.WriteLine(staticMethod());                                                                                             }}
     
    Thanks

    DB:3.77:Abstract Class Private Instance Method cd

    You can use this sample and also visit http://msdn2.microsoft.com/en-us/library/d8ba5k1h.aspx for more information.
     

    Code Block

  • RELEVANCY SCORE 3.74

    DB:3.74:Calling An Abstract Method! ac


    Hi,

    Is it possible to call an abstract method from a non-abstract method within an abstract class?

    DB:3.74:Calling An Abstract Method! ac

    sure it is. indeed, this forms the basis of the Template Method design pattern, where you have an abstract class with some final methods that describe the steps of the algorithm, but the individual steps are implemented as abstract methods to be overriden by concrete subclasses. for example:public abstract class PersonDrawer {
    public final void draw() {
    drawHead();
    drawTorso();
    drawLimbs();
    }

    public abstract void drawHead();
    public abstract void drawTorso();
    public abstract void drawLimbs();
    }the details of drawing various body parts are left up to concrete subclasses, but the algorithm stays the same.

  • RELEVANCY SCORE 3.74

    DB:3.74:Servlet x7


    if HttpServlet is abstract class then HttpServlet have an abstract methods?

    DB:3.74:Servlet x7

    if HttpServlet is abstract class then HttpServlet have an abstract methods?

  • RELEVANCY SCORE 3.74

    DB:3.74:Doubt About Abstract Class 3x


    Windows Computer Role inherit from Computer Role. Windows Computer role only has one property Display Name.
    I've create a abstract custom class A based on Windows Computer Role and I've added one property Property1. Also I've created a Class B hosted by Class A. When I find objects of this class B, I see that have two properties Display
    Name and Property1 (OK). But when I click on Full Path Name I can see a diagram of Windows Computer class with a lot of properties.

    I don't understand because I can notsee Windows computer role properties....
    Does Class B have Windows Computer properties?? Why I can see only 2 properties on console when I find class B Objects?

    DB:3.74:Doubt About Abstract Class 3x

    Hi
    SCOMclass inheritance base class property'sby design. inSCOM console or authoring console you can see only current class property's but not base class, once mp I loaded inSCOM you can see all property'sof base class and currentclass
    as it is logical design. refer below link for more information on classes
    http://technet.microsoft.com/en-us/library/ee957039.aspx
    windows computer class is base class ofwindows computer role
    , due to whichany instance of windows computer role class has all property's of
    windows computer property's
    refer below link for class hierarchy
    http://mpdb.azurewebsites.net/MPDoc/ClassTypeHierarchy
    Regards
    sridhar v

  • RELEVANCY SCORE 3.73

    DB:3.73:Abstract Class And A Static Method a1


    Can i call a static method within an abstract class ?

    DB:3.73:Abstract Class And A Static Method a1

    Simply test this.
    abstract public class Abstract{
    public static void main(String[] args){
    System.out.println("main in an abstract class");
    }
    }

  • RELEVANCY SCORE 3.73

    DB:3.73:Abstract Class 9c


    hi,

    which of the following is true?

    1) abstract class have atleast one abstract method.
    2) all methods in abstract class are abstract.

    thanks.

    DB:3.73:Abstract Class 9c

    Looks like you are new to Java and want to improve your knowledge abt abstract class. For this question, none of the given options is true. For any other doubt, I would suggest you to create a sample code and check it.

  • RELEVANCY SCORE 3.73

    DB:3.73:Interface Vs Abstract Class d8


    when do we need interface and when abstract class?

    DB:3.73:Interface Vs Abstract Class d8

    2.All the abstract methods must be overrided and
    implemented by the child class.by definition, you can't override a method that has no implementation

    3.Real Examples:

    when we implement the ActionListener interface for
    Button click event then we have to override the
    actionPerformed method, we dont have any other
    chices, so it is a way of forcing the inherited class
    to override certain methods.as before, we implement an abstract method. you're not forcing an override, this can't be done, nor would it be a good idea. as discussed at length recently :-)

    n java you can see all the classes that starts with
    Abstract is abstract.not so. there's nothing at all to stop you writing a concrete class named AbstractClass

  • RELEVANCY SCORE 3.71

    DB:3.71:Why Abstract Classes? jx


    Hi friends ..I have a doubt about abstract classes,what is the need of them.

    DB:3.71:Why Abstract Classes? jx

    Check [http://java.sun.com/docs/books/tutorial/java/IandI/abstract.html]

  • RELEVANCY SCORE 3.71

    DB:3.71:Differance Between Abstract Class And Interface 7s


    Whats the main differance between abstract class and Interface and where I can use abstract class and where I can use Interface

    DB:3.71:Differance Between Abstract Class And Interface 7s

    Refer to
    http://www.javaworld.com/javaworld/jw-09-2001/jw-0921-interface.html

  • RELEVANCY SCORE 3.70

    DB:3.70:Ejb2.0 Inheritance In Jboss kd


    hi,

    We are trying to migrate an ejb 2.0 project from Websphere Application Server 6.1 to Jboss 4.2.3.
    Our project has used Entity Bean inheritance using Websphere application server. While we are deploying it
    in jboss the inheritance entites showing sql exceptions as follows.

    Is the entity bean inheritance in ejb 2.0 is supported by jboss application server 4.2?.Please respond as soon as possible.

    Thanks in advance

    Warm Regards

    Jisson Dennis
    ------------------------------------------------------------------------------------------

    Stacktrace

    TransactionRolledbackLocalException in method: public abstract boolean com.eyi.core.persistence.ejb2.PersistentEntity.isDeleted(), causedBy:
    com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'name'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:156)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1373)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:371)

    -------------------------------------------------------------------------------------------------

    Base entity
    -----------

    public abstract class StaffOnProbationBean extends com.eyi.hrms.staff.ejb.StaffLifeCycleStateBean {

    public abstract void setHomeJNDIName(String homeJNDIName);

    public abstract String getHomeJNDIName();

    public abstract java.sql.Date getPlannedEndDate();

    public abstract void setPlannedEndDate(java.sql.Date newPlannedEndDate);

    public abstract short getNoOfTimesExtended();

    public abstract void setNoOfTimesExtended(short newNoOfTimesExtended);

    public abstract boolean getLatest();

    public abstract void setLatest(boolean newLatest);
    }

    ----------------------------------------------------------------------------------------------
    Child Entity
    -----------

    public abstract class StaffLifeCycleStateBean extends com.eyi.oms.persistence.OrganizationalEntityBean implements javax.ejb.EntityBean {

    public void ejbStore()
    {
    preStore();
    }

    public abstract java.lang.String getUUID();

    public abstract void setUUID(java.lang.String newUUID);

    public abstract java.lang.String getName();

    public abstract void setName(java.lang.String newName);

    public abstract boolean getActive();

    public abstract void setActive(boolean newActive);

    public abstract java.lang.String getOfficeID();

    public abstract void setOfficeID(java.lang.String newOfficeID);

    public abstract java.sql.Date getCreatedDate();

    public abstract void setCreatedDate(java.sql.Date newCreatedDate);

    public abstract java.sql.Date getLastModifiedDate();

    public abstract void setLastModifiedDate(java.sql.Date newLastModifiedDate);

    public abstract long getOCA();

    public abstract void setOCA(long newOCA);

    public abstract boolean getDeleted();

    public abstract void setDeleted(boolean newDeleted);

    public abstract java.sql.Date getStartDate();

    public abstract void setStartDate(java.sql.Date newStartDate);

    public abstract java.sql.Date getEndDate();

    public abstract void setEndDate(java.sql.Date newEndDate);

    public abstract java.lang.String getHomeJNDIName();

    public abstract void setHomeJNDIName(java.lang.String newHomeJNDIName);

    public abstract java.util.Collection getRelations();

    public abstract void setRelations(java.util.Collection aRelations);

    public abstract com.eyi.hrms.staff.ejb.Staff getStaff();

    public abstract void setStaff(com.eyi.hrms.staff.ejb.Staff aStaff);

    public com.eyi.core.persistence.PersistentEntityKey ejbCreate()
    throws javax.ejb.CreateException
    {
    return null;
    }

    public void ejbPostCreate() throws javax.ejb.CreateException
    {
    }

    //public abstract java.lang.String getStaff_uUID();

    //public abstract void setStaff_uUID(java.lang.String newStaff_uUID);
    }

    DB:3.70:Ejb2.0 Inheritance In Jboss kd

    hi,

    We are trying to migrate an ejb 2.0 project from Websphere Application Server 6.1 to Jboss 4.2.3.
    Our project has used Entity Bean inheritance using Websphere application server. While we are deploying it
    in jboss the inheritance entites showing sql exceptions as follows.

    Is the entity bean inheritance in ejb 2.0 is supported by jboss application server 4.2?.Please respond as soon as possible.

    Thanks in advance

    Warm Regards

    Jisson Dennis
    ------------------------------------------------------------------------------------------

    Stacktrace

    TransactionRolledbackLocalException in method: public abstract boolean com.eyi.core.persistence.ejb2.PersistentEntity.isDeleted(), causedBy:
    com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'name'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:156)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1373)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:371)

    -------------------------------------------------------------------------------------------------

    Base entity
    -----------

    public abstract class StaffOnProbationBean extends com.eyi.hrms.staff.ejb.StaffLifeCycleStateBean {

    public abstract void setHomeJNDIName(String homeJNDIName);

    public abstract String getHomeJNDIName();

    public abstract java.sql.Date getPlannedEndDate();

    public abstract void setPlannedEndDate(java.sql.Date newPlannedEndDate);

    public abstract short getNoOfTimesExtended();

    public abstract void setNoOfTimesExtended(short newNoOfTimesExtended);

    public abstract boolean getLatest();

    public abstract void setLatest(boolean newLatest);
    }

    ----------------------------------------------------------------------------------------------
    Child Entity
    -----------

    public abstract class StaffLifeCycleStateBean extends com.eyi.oms.persistence.OrganizationalEntityBean implements javax.ejb.EntityBean {

    public void ejbStore()
    {
    preStore();
    }

    public abstract java.lang.String getUUID();

    public abstract void setUUID(java.lang.String newUUID);

    public abstract java.lang.String getName();

    public abstract void setName(java.lang.String newName);

    public abstract boolean getActive();

    public abstract void setActive(boolean newActive);

    public abstract java.lang.String getOfficeID();

    public abstract void setOfficeID(java.lang.String newOfficeID);

    public abstract java.sql.Date getCreatedDate();

    public abstract void setCreatedDate(java.sql.Date newCreatedDate);

    public abstract java.sql.Date getLastModifiedDate();

    public abstract void setLastModifiedDate(java.sql.Date newLastModifiedDate);

    public abstract long getOCA();

    public abstract void setOCA(long newOCA);

    public abstract boolean getDeleted();

    public abstract void setDeleted(boolean newDeleted);

    public abstract java.sql.Date getStartDate();

    public abstract void setStartDate(java.sql.Date newStartDate);

    public abstract java.sql.Date getEndDate();

    public abstract void setEndDate(java.sql.Date newEndDate);

    public abstract java.lang.String getHomeJNDIName();

    public abstract void setHomeJNDIName(java.lang.String newHomeJNDIName);

    public abstract java.util.Collection getRelations();

    public abstract void setRelations(java.util.Collection aRelations);

    public abstract com.eyi.hrms.staff.ejb.Staff getStaff();

    public abstract void setStaff(com.eyi.hrms.staff.ejb.Staff aStaff);

    public com.eyi.core.persistence.PersistentEntityKey ejbCreate()
    throws javax.ejb.CreateException
    {
    return null;
    }

    public void ejbPostCreate() throws javax.ejb.CreateException
    {
    }

    //public abstract java.lang.String getStaff_uUID();

    //public abstract void setStaff_uUID(java.lang.String newStaff_uUID);
    }

  • RELEVANCY SCORE 3.70

    DB:3.70:Can We Write Constructor For Abstract Class? 83


    Can we write Constructor for Abstract class?

    DB:3.70:Can We Write Constructor For Abstract Class? 83

    Somebody's knee-deep in Grolsch.Who? Who is? Whowhowho? Tellmetellmetellme!

    kind regards,

    Jos (the liquor store guy still didn't refill my stock ... thirsty ;-)

  • RELEVANCY SCORE 3.62

    DB:3.62:Re: Abstract Classes mp


    Delete constructor from your person abstract class, 'cause abstract class cann't be instantiated. Or better alternative to delete abstract keyword.

  • RELEVANCY SCORE 3.61

    DB:3.61:Make Abstract Class With Interface. 39


    I want to make an abstract class with methods that need interfacing, but I don't want to make an entire other class for the abstract class to implement. Is there any way to make an abstract class and interface combined into one class with no implementations on that class?

    DB:3.61:Make Abstract Class With Interface. 39

    if you want a class with no implementations that what you need is an Interface

  • RELEVANCY SCORE 3.61

    DB:3.61:Abstract Class Vs Interface 1x


    Hi I have a small doubt regarding this.
    When can i go for Abstract Class and When can i go for Interface.
    Anybody can help me?

    DB:3.61:Abstract Class Vs Interface 1x

    Hi I have a small doubt regarding this.
    When can i go for Abstract Class and When can i go for Interface.
    Anybody can help me?

  • RELEVANCY SCORE 3.60

    DB:3.60:How Can A Jspwriter Abstract Class Have An 'Out' Object m7


    Jsp writer is an abstract class.In scriplets to print htmls directly we use "out" object.This "*out" is the implicit object* of jspWriter.

    My doubt is how can an abstract Class(JspWriter) have an object as abstract classes cannot have objects as they cannot be instantiated

    DB:3.60:How Can A Jspwriter Abstract Class Have An 'Out' Object m7

    Because the object out references is of a concrete class which extends JSPWriter and is supplied by your server environment. It will be a vendor specific class.

  • RELEVANCY SCORE 3.58

    DB:3.58:Please Solve The Java Puzzle And Give Soiution With Reason fx


    what wil be the output for this. please help me...

    abstract class test
    {
    abstract void add(int x,int y);
    }

    interface inter
    {
    void add(int x,int y);
    }
    class testMain extends test implements inter
    {
    public static void main(String arg[])
    {
    public void add(int x,int y)
    {
    system.out.println(x+y);
    }

    }
    testMain t=new testMain();
    t.add(2,4);
    }
    }

    my doubt is what wil call either abstract class or interface.
    i don`t know the answer.
    please help me.

    thanking you java tiger

    DB:3.58:Please Solve The Java Puzzle And Give Soiution With Reason fx

    very thank you man.
    i just new to java. so i created my doubt with lot of error. thank you very much.

  • RELEVANCY SCORE 3.58

    DB:3.58:Webmethod With Abstract Parameter + Json fm


    Hi people.

    I have a doubt about posing a JSON object via jQuery AJAX.

    I've created a project (Framework 3.5) with the following classes:

    namespace WebApplication1.Entities
    {
    public abstract class APeopleEntity
    {
    public long Id { get; set; }

    public string Name { get; set; }

    public APeopleEntity()
    {
    }

    public APeopleEntity(long id, string name)
    {
    Id = id;
    Name = name;
    }
    }

    public class PeopleEntity : APeopleEntity
    {
    public PeopleEntity()
    : base()
    {
    }

    public PeopleEntity(long id, string name)
    : base(id, name)
    {
    }
    }
    }

  • RELEVANCY SCORE 3.58

    DB:3.58:A Problem About The Abstract Class And The Abstract Method, Coming For Help mc


    Why the abstract method getScreenSize() in the abstract class java.awt.Toolkit class can be called and return the right result?

    DB:3.58:A Problem About The Abstract Class And The Abstract Method, Coming For Help mc

    to paulcw:
    Yes, that's the very answer i'm looking for. Thanks for your reply, that really helps.

  • RELEVANCY SCORE 3.56

    DB:3.56:I Need Clarification In Interface And Abstract Class fk


    Hi friends, i have simple doubt in interface and abstract class. Here you can find my example program. Please send me the difference in this programme.

    abstract class abc {
    abstract void draw();
    }

    interface def {
    void draw();
    }

    Here i have interface and abstract class and each have method called draw. What is the difference in this. whenever i am extends the draw()method i can use different places in different behaviour(like i can draw the elipse, circle and other things). I hope same thing i can achive through implementing interface also. If anybody well in this concept please explain to me.

    Thanks
    suresh

    DB:3.56:I Need Clarification In Interface And Abstract Class fk

    to mattbunch

    That was kind of confusing. Were you trying to say that an Interface somehow makes objects more inheritable?

    If the class doen't inherit from abc but does inherit from some class
    other than Object, then you can't do it, even if you alter the code. Everything inherits from Object no matter how it was defined.

  • RELEVANCY SCORE 3.55

    DB:3.55:Doubt In Outputstream Class 7d


    Hi,
    I was looking at the (Sun's) API documentation of the 'OutputStream' class.
    It says "Applications that need to define a subclass of OutputClass must always provide at least a method that writes one byte of output".

    why MUST a sub class of OutputClass declare one such method? I could as well declare my class (that sub classes OutputClass) as abstract.

    Can someone explain this?
    TIA,
    Babu

  • RELEVANCY SCORE 3.55

    DB:3.55:Difference Between Abstract Class And The Normal Class 7k


    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...../

    DB:3.55:Difference Between Abstract Class And The Normal Class 7k

    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.

  • RELEVANCY SCORE 3.54

    DB:3.54:Enum-Questions js


    I hav e some doubt about enum, searched but couldnt find the answer.

    1.. Why cant enum extend class although they are allowed to implement interfaces.

    2..Even though enum are implicitily final why does it permit to define
    abstract method in it.

    DB:3.54:Enum-Questions js

    I hav e some doubt about enum, searched but couldnt
    find the answer.

    1.. Why cant enum extend class although they are
    allowed to implement interfaces.Good question. I don't know. Most probably, because implicitly each enum DOES inherit from the enum superclass. Since Java won't allow you multi-inheritance, you can't inherit from anything else.

    2..Even though enum are implicitily final why does it
    permit to define
    abstract method in it.Yeah, well, the enum members aren't. For example:

    enum someEnum{

    ENUM1{
    doSth(){}
    },
    ENUM2{
    doSth(){}
    }

    public abstract void doSth();
    }As you can see, you can add behavior to each enum member. If you want to make this behavior available for the whole enum, you have to declare an abstract method. You don't have to make it abstract, so you would have something like a default behaviour, but this really is the same discussion as with every other abstract class, too...

  • RELEVANCY SCORE 3.52

    DB:3.52:Abstract Class m3


    hi
    Can we have a constructor for an abstract class, and can we
    create an object for an abstract class?

    regards.

    DB:3.52:Abstract Class m3

    tjacobs01 wrote:
    JComponent jc = new JComponent(); //won't work
    JComponent jc2 = new JComponent() {}; //this works

    See the difference?(You may need glasses to see the difference ;-)

  • RELEVANCY SCORE 3.50

    DB:3.50:Re: Interface m8


    Java Glossary : interface vs abstract class
    Abstract classes vs. interfaces: When does it make sense to choose an abstract class over an interface?
    Abstract classes and interfaces practicum: Move from theory to practice on when to employ abstract classes vs. interfaces
    Tech Tips: ABSTRACT CLASSES VS. INTERFACES

    DB:3.50:Re: Interface m8

    I'm still entertained by the fact that some folks will
    spell out words like "multiple", "inheritance",
    "interface", and "implement", but not "because".

    :o)LOL!

    This kills me - just bcuz.

    %

  • RELEVANCY SCORE 3.50

    DB:3.50:Abstract Class 13


    Difference between abstract class and interface
    use of abstract class

    DB:3.50:Abstract Class 13

    This question has been asked here about a billion times:

    http://search.java.sun.com/search/java/index.jsp?qt=interfacenh=10qp=st=11rf=0since=country=language=charset=variant=col=javaforums

  • RELEVANCY SCORE 3.50

    DB:3.50:Abstract Class fd


    why we can not create object of an abstract class.

    DB:3.50:Abstract Class fd

    How many dodos were born last year?too many to count

  • RELEVANCY SCORE 3.50

    DB:3.50:Abstract Methods... j9


    Hi i was going over abstract Classes and methods , I understood the abstract classes pretty well (they are basically used as parent super classes) but i still am not sure about abstract methods.. I know that if a class has an abstract method then that class must also be declared as an abstract class ... I know that abstract methods dont have a body ? Could anyone please give me why abstract methods are used and explain them thanks ....

    DB:3.50:Abstract Methods... j9

    SilverChips wrote:
    Thanks for the help man ... that what i needed to know. Glad you're moving forward. :)

  • RELEVANCY SCORE 3.50

    DB:3.50:[C++/Cli] Suggestion For Abstract Method Notation c9


    When declaring an abstract method in C++/CLI, the following is equivalent:ref class Abstract abstract{
    virtual void abstract_method() abstract;

    DB:3.50:[C++/Cli] Suggestion For Abstract Method Notation c9

    Post this suggestion at http://connect.microsoft.com/VisualStudio.

  • RELEVANCY SCORE 3.50

    DB:3.50:Abstract Class zx


    Hi,
    When to prefer abstract class without any method as abstract?

    Regards
    SamyMohan

    DB:3.50:Abstract Class zx

    wait grr.. I think I got it backward :-p.
    You need to implement abstract methods, and you do not need to implement non-abstract methods (but you can).
    ~sorry, I just woke up

  • RELEVANCY SCORE 3.50

    DB:3.50:How Abstract Class Works? 13


    hello, every!

    i can't quite understand the abstract class.

    can a abstract class be inherited by a class in different package?

    thanks!

  • RELEVANCY SCORE 3.50

    DB:3.50:Difference Between A Abstract Class With 4 Abstract Methods And A Interface With 4 Abstract Methods. 8c


    what is the difference between Difference between a Abstract class with 4 abstract methods and a Interface with 4 abstract methods.

    DB:3.50:Difference Between A Abstract Class With 4 Abstract Methods And A Interface With 4 Abstract Methods. 8c

    Your question is better rephrased as: What is the difference between an abstract class and a interfase?
    This has been discused here
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/67451957-f0bd-4b9b-a2c0-16f604ce8643
    Regards

  • RELEVANCY SCORE 3.50

    DB:3.50:Difference Between Inheritance And Abstract Class 9s


    difference between inheritance and abstract class

    DB:3.50:Difference Between Inheritance And Abstract Class 9s

    There was never an episode of Blackadder where he tried to con his aunt out of an abstract class

  • RELEVANCY SCORE 3.50

    DB:3.50:Diference Between Abstract Class And Interface cp



     
    Hi,
     
    I had a doubt on basic concept of interface and abstract class.
     
    I had idea of wht is interface and abstract class but there is case ,can any do justification on these case is
     
    Abstract class is a clas where some methods r defined and some are abstract methods.
    Interface is where all methods are abstract .
     
    but what happen if i try to maintaince all methods in abstract class as abstract which is equivalent to interface.?
     
    We go for abstract class if want to extend functionality of class.For interface if we wanna implement a new implementation.
     
    is there any other difference apart from this and other issues if we try to have all methods abstract .
     
     
    With regards
    Mahender

    DB:3.50:Diference Between Abstract Class And Interface cp

    Hi,
     
    Thnx for giving info.Actually iam looking for projct development point of view..In whihc cases i do go 4 developing abstract classes  other interfaces

  • RELEVANCY SCORE 3.50

    DB:3.50:In Which Case We Need : An Abstract Class With No Abstract Methods.... 9p


    Does it make sense to have an abstract class with no abstract methods. (means any design pattern or scenario)

    DB:3.50:In Which Case We Need : An Abstract Class With No Abstract Methods.... 9p

    Most of (or maybe all) the adapter classes corresponding to AWT listeners are abstract with no abstract methods. These classes are abstract as it just doesn't make sense to use a listener that does nothing.

  • RELEVANCY SCORE 3.50

    DB:3.50:Can Abstract Classes Inherit Abstract Methods Without Implementing Them? dj



    Keeping with your example: Just remove the declaration of DoSomething() from the Bar class. Since the class is declared as abstract, it doesn't need to implement any abstract methods from its base class.


    public abstract class Foo : MonoBehaviour { public abstract void DoSomething (); }


    public abstract class Bar : Foo { // No declaration of DoSomething(); // Just add new methods. }

    DB:3.50:Can Abstract Classes Inherit Abstract Methods Without Implementing Them? dj


    Keeping with your example: Just remove the declaration of DoSomething() from the Bar class. Since the class is declared as abstract, it doesn't need to implement any abstract methods from its base class.


    public abstract class Foo : MonoBehaviour { public abstract void DoSomething (); }


    public abstract class Bar : Foo { // No declaration of DoSomething(); // Just add new methods. }

  • RELEVANCY SCORE 3.50

    DB:3.50:Geting Subclass Info From Abstract Class jc


    Does ne one know how i can retreive informtion from the subclasses of an abstract class by creatinig an instance of the abstract class.

    are Methods such as getClass used?

    DB:3.50:Geting Subclass Info From Abstract Class jc

    Cast your HorDent and HinDent objects to Dent and call
    the above method. No need to explicitly cast to a super-type.

  • RELEVANCY SCORE 3.50

    DB:3.50:Inner Classes ks


    Inner classes can contain abstract methods. So that inner class will become abstract class. Now my doubt
    is , will the outer class become abstract too?

    DB:3.50:Inner Classes ks

    You can define an abstract class inside another class, an interface, or inside a method (private to that method)
    Where you define it changes its scope, the file it is defined in and the name of the class fie. I don't think there is anything else to it.

  • RELEVANCY SCORE 3.50

    DB:3.50:Abstract Class sc


    What is the use of Abstract class with no abstract methods? Please let me a scnerio where this is used instead of a Normal class

    DB:3.50:Abstract Class sc

    There really isn't much point in such a class at all. But let me turn the question around: what would be the point of requiring an abstract class to have at least one abstract method?

  • RELEVANCY SCORE 3.48

    DB:3.48:What Is Need Of Constructor Is Abstract Class? jj


    we con't creat a object for abstract class than what is need of constractor in abstract class?

    DB:3.48:What Is Need Of Constructor Is Abstract Class? jj

    An abstract class doesn't necessarily have to have no implementation; there could be concrete methods as well as abstract ones. And an abstract can have instance variables too.

    When a subclass is instantiated, it will call the constructor of it's superclass which will call it's own superclass' constructor and so on till the constructor of the Object class is reached. Even if your class doesn't extend anything, by default it will extend Object (everything in Java extends Object directly or indirectly)

    For example, consider that you have an abstract class 'Animal' that looks like this:

    public abstract class Animal
    {
    private String name;

    public String getName()
    {return name;}

    public Animal (String name) //1-arg contructor
    {this.name = name;} //it will set the value for the instance variable
    //just like for a concrete class
    }and a class Dog that extends this
    public class Dog
    {
    public Dog (String name)
    {super(name);}//call the constructor of abstract superclass
    }The constructor is not there to instantiate the abstract itself, you can't do that. But rather, think of this way, an instance of a class is the sum of all it's superclasses; think of concentric circles with the innermost being the Object class part, then the Animal class part and finally, the Dog class part. So in effect, you're making a part of the Dog object which is defined by the abstract Animal class that it extends which itself implicitly extends Object.

    So you're getting the behaviour for wait(), notify() etc from Object, the behaviour for getName() from Animal; all as part of the Dog object.

    Edited by: nogoodatcoding on Oct 19, 2007 3:48 PM

  • RELEVANCY SCORE 3.48

    DB:3.48:Re: Doubt In Abstract Class 8x


    I have come across at many companies. Why do interviewer( who conducts technical interview) need to know about background of the candidate, like family background, education, etc. I thought this is the job of HR.
    Am i correct?
    I would really like to know how a actual interview look like.

    DB:3.48:Re: Doubt In Abstract Class 8x

    Actually, depending on your definition of
    "instantiate", it is possible to instantiate an
    Abstract class, but only through an implementing
    class in the constructor using (explicitly or
    implicitly), super(). Whenever you instantiate
    a class, you are implicitly instantiating all of its
    superclasses.Hi, You got some weird definitions. You do only say that you are creating one instance when you are executing a constructor. It doesn't matter that the class extends or implements other classes. It sounds like you think that the call to super creates an instance of the superclass, it doesn't.

    Kaj

  • RELEVANCY SCORE 3.47

    DB:3.47:Doubt On Abstract Classes dp


    Hi,
    I have doubt in abstract classes,please clarify my doubt.....my doubt is
    I have one abstract class,in that i have three methods...
    Now I have created one subclass for that abstract class....
    I defined all those methods that are there in abstract class in the sub class......and I wrote some other methods in that sub class....
    Now my question is -----can I make the methods that are declared in abstract class invisible to the people who are using the sub class???

    Please tell me the answer...

    Thanks in advance,
    sirisha.

    DB:3.47:Doubt On Abstract Classes dp

    Please see the code and tell me wether it is correct or not...Your compiler will show you...

    ... and tell you what's wrong with super.display()

  • RELEVANCY SCORE 3.46

    DB:3.46:Difference Between Interface And Abstract Class a1


    Hi sirs,

    Give me the differences between interface and abstract class
    and when we go for interfaces and abstract class in developing an application

    DB:3.46:Difference Between Interface And Abstract Class a1

    An interface is a 100% abstract class, which means it doesn't contain any code, just method names and signatures. You use abstract classes when you want some code to be shared among the inheritors.

    The advantage with interface is that a class can implement as many interfaces as you like, while it can only extend one (abstract) class.

    So, you use interfaces when you need to extend other classes or doesn't want any code shared, and abstract classes when you don't want to extend other classes, and would like to share some code.

  • RELEVANCY SCORE 3.46

    DB:3.46:Using Abstract Class And Interface Class m9


    hi, i have a big doubt that at what scenario should i go for abstract class and what scenario should i go for Interface. because i googled and got info. but still i cudn't have an idea of the situation to use these two paradigms. so please share me the knowledge about this nice concepts.loving dotnet

    DB:3.46:Using Abstract Class And Interface Class m9

    If you need basic implementation that is shared in several classes that derive, go for an abstract class. In all other cases, go for an interface because you can implement as much interfaces in a class as you want, but only 1 class (so don't waste it just to force some method definitions).

    Geert van Horrik - CatenaLogicVisit my blog: http://blog.catenalogic.comLooking for a way to deploy your updates to all your clients? Try Updater!

  • RELEVANCY SCORE 3.46

    DB:3.46:Re: Public Abstract Static... In Abstract Class? 39


    And have you ever heard about instanceof or getClass()?

    DB:3.46:Re: Public Abstract Static... In Abstract Class? 39

    I second rene's opinion that the design stinks. If you need to do something like this, then generally it means you are trying to do something outside the Ping or Pong class that should be done inside the class. For example:
    if (packet.getPacketType() == Packet.PING)
    doSomething();
    else if (packet.getPacketType() == Packet.PONG)
    doSomethingElse(); Should probably be handled like:
    public abstract class Pacaket {
    public abstract void doThing();
    }
    public class Ping extends Packet {
    public void doThing() { doSomething(); }
    public void soSomeThing() { ... }
    }
    public class Pong extends Packet {
    public void doThing() { doSomethingElse(); }
    public void doSomethingElse() { ... }
    }

    //...
    packet.doThing();

  • RELEVANCY SCORE 3.46

    DB:3.46:Dubut In Both Genericservlet And Httpservlet Class 3f


    Although we had conceptually an abstract Class can't be instantiated even as Derived Class must implement/override all method of an abstract Class,but I have a doubt in employing of both GenericServlet and HttpServlet Class,are as follows.
    (1)Even if we can implement GenericServlet/HttpServlet for the user- defined servlet class,that servlet may override merely doGet(),doPost().etc,but not all methods.

    (2)How will happend when a Servlet Class implement GenericServlet/HttpServlet,and we aren't stipulating that servlet class as abstract.

    May anybody steer me plz?

    With Regards
    Stalin.G

    DB:3.46:Dubut In Both Genericservlet And Httpservlet Class 3f

    You're a little confused about this. GenericServlet is an abstract class, as such it cannot be instantiated and can have abstract methods i.e a method with no body. In this case, it is the service() method which must be overriden in the subclass.

    The HttpServlet class is also abstract and it extends the GenericServlet class. However, it provides a default implementation for methods; service(), doGet(), doPost() all have some default implementation so if you simply subclass HttpServlet and add nothing else in it, it will still compile and run. Except that the default implementation of doXXX() methods send back an error of 405 not supported/ implemented

    So the difference is that if you extend GenericServlet and want to make a concrete class you have to override the service() method atleast.

    If you extend HttpServlet, you do NOT have to do anything. Except that your servlet will be pretty much useless.

  • RELEVANCY SCORE 3.46

    DB:3.46:C#, Default Implementation Of Abstract Class Abstract Method 1d


     
    Hi!
     
    How do you provide default implementation of an abstract class' abstract method in the derived class? Please explain.
     
    Thank you.

    DB:3.46:C#, Default Implementation Of Abstract Class Abstract Method 1d

    You want to use 'virtual', not 'abstract' for the method declaration.  Abstract means virtual with no definition in that class.

  • RELEVANCY SCORE 3.42

    DB:3.42:Abstract Classes kc


    what is the main purpose of abstract classes. why abstract class do not throw exceptions.

    DB:3.42:Abstract Classes kc

    Hi,

    Why are classes implementing EntityBeans defined as Local declared as abstact classes.

    Seetesh

  • RELEVANCY SCORE 3.41

    DB:3.41:Create Object For Abstract Class? ps


    Is any way to create object for an abstract class?

    DB:3.41:Create Object For Abstract Class? ps

    anonymous class means that a class is created and
    instantiated in a single line.. but how come abstract
    class allows this instantiation when there should be
    no way to create a object.. ?..

    is this a flaw or something ?..it's not the abstract class that's being instantiated, it's an anonymous concrete subclass that's being instantiated. don't be misled into confusing the reference type (AbstractClass) and the object itself, which is anonymous. consider the following

    Object a = new JFrame();we have a reference to an object, but the reference points to an instance of JFrame. same in my example, it's a reference to AbstractClass, but an instance of a subclass of AbstractClass. you need to understand the difference between references and objects

  • RELEVANCY SCORE 3.41

    DB:3.41:Abstract Class z3


    hi
    why we are declaraing a class as abstract.. Instead of declaring abstract , we can write the method inside the class and override it when neccessary by extending it.
    thanks

    DB:3.41:Abstract Class z3

    I think what you are trying to express is "why have abstract methods, methods without
    implementations, when you can always provide a 'dummy' implementation and then
    override that in concrete subclasses."

    I believe the main problem with that is that it's easy to forget to override this method,
    and this mistake can be discovered at compile-time, thanks to abstract methods.

  • RELEVANCY SCORE 3.41

    DB:3.41:Interface Vs Abstract Class 97


    Hi All,
    Here I have a doubt.
    What is the difference between an bInterface/b and bAbstract class/b(Design Point of View)??.
    In which scenario which is useful.
    Can anybody kindly reply me.

    Thanks and Regards,
    Krishna Mattam
    Team Member - CDF Toolset
    Contact:044-22548575
    Email: mkrish17@ford.com

    DB:3.41:Interface Vs Abstract Class 97

    can you pls send the link to that chapter 4.6I haven't seen it online. You probably will have to buy a paper copy. It's published by Sun. It's the authorative reference on Java so it's worth having.

  • RELEVANCY SCORE 3.40

    DB:3.40:Non-Abstract Methods In A Abstract Class fj


    Abstract Class can contain Non-abstract methods.
    and Abstract Classes are not instantiable as well
    So,
    What is the purpose of Non-abstract methods in a Abstract class.
    since we can't create objects and use it

    so these non-abstract methods are only available to subclasses.
    (if the subclass is not marked as abstract)
    is that the advantage that has.(availability in subclass)

    ??

    DB:3.40:Non-Abstract Methods In A Abstract Class fj

    so these non-abstract methods are only available to
    subclasses.If they're public, they're available to any user of the class or of its concrete subclass. Same as the abstract metods. Same as interface methods. Same as public methods in a concrete class.

  • RELEVANCY SCORE 3.40

    DB:3.40:Can An Abstract Class Extend Another Abstract Class? p1


    Is it possible for an abstract class to extend another abstract class?

    Say
    public abstract class AComponent extends JComponent {
    }

    Thanks.

  • RELEVANCY SCORE 3.40

    DB:3.40:Constructor In Abstract Class 38


    What is the use of constructor in abstract class?

    DB:3.40:Constructor In Abstract Class 38

    An abstract class has fields etc. of it's own, which will require intialization. In fact the constructor in the super class may require arguments passed from the concrete class constructor.

    Constructors in abstract classes should generally be declared as protected and are always called from the concrete classes constructor, either through super() or implicitly.

  • RELEVANCY SCORE 3.39

    DB:3.39:Use Of Abstract And Interface? k3


    when i use Abstract class or Interface.Which one is better?

    DB:3.39:Use Of Abstract And Interface? k3

    Depends on what you want to do. An interface is more general (in that it doesn't define any actual behavior) and allows you to mimic multiple inheritance (a class can implement any number of interfaces whereas it can only extend one class (abstract or otherwise)). Abstract is good if you have a common base of functionality that all of the implementers will be using.

    It's also fairly common to use both (i.e. the interface TableModel and the abstract class AbstractTableModel), so that someone who wants to completely write their own implementation is free to, while someone who wants to just extend or change the standard functionality could do that as well.

  • RELEVANCY SCORE 3.39

    DB:3.39:The Object Class aa


    Hi! World,
    I don't have a question, but a doubt and would like to share and get clarified by u people out there.
    Don't u think the Object class in Java should be an abstract class. We never instanstiate it, all classes in Java just extend it, so why is not an abstract?
    There may be reasons why it's not abstract, but I can site it out..........could u people put some light on this.

    Thanx,
    Chandan.

    DB:3.39:The Object Class aa

    Thanx jsalonen, it was great going through the discussions on this topic. Actually this doubt occured in the minds of one of my colleagues, I gave him some answers like it's a complete class, and it's not abtract so that u can create the rawest of objects in Java, but was myself not very convinced..........I guess the discussion were exactly on the same lines I had tought. Now I will be able to counter my colleagues queries better..........

    Thanx a lot........
    Chandan

  • RELEVANCY SCORE 3.39

    DB:3.39:Abstract Class And Interface 97


    is it any differences between abstract class and interface?

    DB:3.39:Abstract Class And Interface 97

    And of course you [url http://onesearch.sun.com/search/developers/index.jsp?col=devforumsqp_name=Java+Programmingqp=forum%3A31qt=%22+differences+between+abstract+class+and+interface%22] searched first....

    Mike

  • RELEVANCY SCORE 3.39

    DB:3.39:Abstraction 3p


    if a class extends an abstract class does the subclass have to implement all abstract methods in the abstract class?
    e.g
    abstract class Shape
    {
    public abstract double area();
    public abstract double perimeter();
    }
    class Rec Extends Shape
    {
    }
    --- Does class Rec have to implement both area() and perimeter() methods or can it choose to implement area only? Please help

  • RELEVANCY SCORE 3.39

    DB:3.39:Why Httpservlet Is Declared As Abstract 9m


    Why HttpServlet class is declared as an abstract although it does not have any abstract method.

    What logic made designer to make it abstract ?

    Can anyone tell me please.

    Thanks

    DB:3.39:Why Httpservlet Is Declared As Abstract 9m

    Thanks tolmank .
    Now i give u Duke Dollars...
    Cheers!!!!!

  • RELEVANCY SCORE 3.39

    DB:3.39:Abstract Class 8k


    hiii,
    can u give an practical(program) example for abstract class

    DB:3.39:Abstract Class 8k

    CRKC wrote:
    hiii,
    can u give an practical(program) example for abstract classThe java.util.AbstractList class is a good example. It supplies almost a full ArrayList implementation. If you extend it you only need to impelement two methods and you got your very own MyArrayList.

  • RELEVANCY SCORE 3.39

    DB:3.39:Re: How Can An Abstract Class Have No Abstract Methods? d3


    A compile-time error only occurs when you declare an abstract method, but dont declare the class as abstract.
    If the class is abstract, but no method inside it is abstract, no compile-time error occurs (why should it occur?)
    but why should anybody declare the class as abstract anyway in that case (what sense does it make?)?

    regards

    BB

    DB:3.39:Re: How Can An Abstract Class Have No Abstract Methods? d3

    Great to see that you want to help, but please, don't resurrect old threads (especially not if they already have been answered). I'm locking this thread.

    Kaj

  • RELEVANCY SCORE 3.35

    DB:3.35:Abstract Class And Interface 7x


    Hi,
    This is ramana, I got a doubt
    1. I have one interface
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }
    2. Iam trying to convert that interface into abstract class like below
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }
    3. Again iam trying to extend that abstract class into class like below
    interface Intabs {
    abstract void method1();
    abstract void method2();
    abstract void method();

    }

    Iam getting errors

    Can i do it in multiple steps: Interface------abstract class----- class

    DB:3.35:Abstract Class And Interface 7x

    Cannot reduce the visibility of the inherited method
    from IntabsDerabst1.java
    Right. As mentioned, you can't assign weaker access priveleges to inherited methods. If you define a method as "public void foo() {}", the "foo()" method must have at least public access in all subtypes. In your example, your interface methods are public, but you're trying to give them "package-private" (default) access in the abstract and concrete implementation classes.

    ~

  • RELEVANCY SCORE 3.35

    DB:3.35:Abstract Class And Interface z1


    What is most important thing about abstract class and interface.

    When to use abstract class and interface.

    DB:3.35:Abstract Class And Interface z1

    The interface is like an agreement where the class
    which implements the interface promises to write the
    implementation code for all the functions in the
    interface.Same for an abstract class, only, rather than "all the methods" it's "all the abstract methods." Of course, you could turn around and usethat wording for interfaces too, but in that case it means "all the methods" since interfaces' methods are all abstract.

  • RELEVANCY SCORE 3.35

    DB:3.35:Question About Abstract Classes cz


    abstract class Animal
    {
    abstract boolean alive();
    }

    class Dog extends Animal
    {
    public int age;
    }

    class Test
    {
    public void main(String args[])
    {
    Animal a = new Dog();
    a.age = 2; // == Doesn't work, why?
    }
    }

    DB:3.35:Question About Abstract Classes cz

    abstract class Animal
    {
    abstract boolean alive();
    }

    class Dog extends Animal
    {
    public int age;
    }

    class Test
    {
    public void main(String args[])
    {
    Animal a = new Dog();
    a.age = 2; // == Doesn't work, why?
    }
    }because a is an "Animal" and you didn't specify that all "Animal"s have an "age" - only that "Dog"s do. So of course you would have had to do:
    Dog a = new Dog();
    a.age = 2;

    (It still wouldn't have compiled anyway however, because you didn't implement the "alive" method in Dog)

  • RELEVANCY SCORE 3.35

    DB:3.35:Abstract Class And Concrete Class am


    I can't understand why need to creat Abstract class.What's the actual purpose to creat Concrete class to overrides or implements Abstract class methods?
    Help me to understand.

    DB:3.35:Abstract Class And Concrete Class am

    I can't understand why need to creat Abstract
    class.What's the actual purpose to creat Concrete
    class to overrides or implements Abstract class
    methods?
    Help me to understand.A class that's not completely concrete cannot be instantiated (objects cannot be created).

  • RELEVANCY SCORE 3.35

    DB:3.35:Return Abstract Base Class Type Pointer From The Derived Class jc


    I have a big doubt on how to return pointer instance of abstract base class from its derived class.
    For example,
    inXerces data object model, DOMDocument is an abstract class and hence it cannot be instantiated.(Error:
    DOMDocument* doc=new DOMDocument()).
    Then how, the class XercesDOMParser can return DOMDocument* type without the instantiation of
    DOMDocument class.
    XercesDOMParser* myParser=new XercesDOMParser();
    DOMDocument* doc=myParser-getDocument();

    DB:3.35:Return Abstract Base Class Type Pointer From The Derived Class jc

    Dear Dave,
    This sounds good. Thanks a lot. Thanks to Aljod too...

  • RELEVANCY SCORE 3.34

    DB:3.34:Java Interfaces And Abstract Classed fc


    what is the difference between interface and abstract class?

    DB:3.34:Java Interfaces And Abstract Classed fc

    I suggest you try writing some code and see.

  • RELEVANCY SCORE 3.34

    DB:3.34:How Abstract Class Differ, When We Call Class To Be Abstract Data Type? 7f


    We say as Classes as a realization of Abstract data types, then why should we declare that to be abstract ?

    Hope, the key word Abstract in both ADT and abstract classname mean the same.!!!!

    DB:3.34:How Abstract Class Differ, When We Call Class To Be Abstract Data Type? 7f

    No, abstract is in the case of "abstract data type" a more general term, whereas in "abstract class" it is a technical term in Java.

    Are you not satisfied with the answers here?
    http://forum.java.sun.com/thread.jspa?threadID=5303930messageID=10297137#10297137

  • RELEVANCY SCORE 3.32

    DB:3.32:Abstract Class Extends Other Class? cs


    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;
    }
    }

    DB:3.32:Abstract Class Extends Other Class? cs

    shafiur wrote:
    Why do we need an abstract class that extends other class?Addiction to inheritance?

  • RELEVANCY SCORE 3.32

    DB:3.32:Doubt In Interface. 1z


    In Java we cannot create objects for an interface and abstract class.But the java.sql.Statement is an interface and how are we able to get an object of that class ?
    Please mail the answer to
    chinmaychotaray@gmail.com

    DB:3.32:Doubt In Interface. 1z

    As you have specified that we can't create an object to an interface, but we can create a reference to it.
    And this reference can be used to point to any object of a calss which implements this interface.
    Here java.sql.Statement is an interface, and DriverMangaer class takes responsibility to take connection from DB. DB vendor provides implementation to these interfaces, so here we r porviding the implementation to Statement interface we can use like this,
    Statement stmt=Connection-obj.createStatement().

  • RELEVANCY SCORE 3.32

    DB:3.32:Test If Class Is Abstract By Reflection 3a


    Hi, may I find out if a some class is declared as abstract using class reflection??
    Radim

    DB:3.32:Test If Class Is Abstract By Reflection 3a

    thanks
    Class.GetModifiers() is the right method.

    Class.isInterface() is not for this test because
    relation between class and interface is defined in jvm as interface is naturally abstract (abstract class is not interface)...

  • RELEVANCY SCORE 3.32

    DB:3.32:Abstract Class Needs To Implement Interface ms


    Hello, I have an interface and base abstract class defined as follows: interface IbusinessInterface{    void DoSth1();    void DoSth2();    void DoSth3();    void DoSth4();    void DoSth5();    ...    ...    void DoSthN();}public abstract class BaseClass : IBusinessInterface{    public abstract void DoSth1();    public abstract void DoSth2();    public abstract void DoSth3();    public abstract void DoSth4();    public abstract void DoSth5();    ...    ...    public abstract void DoSthN();} what is the reason that this abstract class needs to have methods of the interface implemented  ?Thanks, Michal

    DB:3.32:Abstract Class Needs To Implement Interface ms

    Look at the other side of the coin!  Think interface contract.  The abstract base class is NOT defining any default implementation for you.  Now, when you browse the abstract class you can SEE the member methods that are or not implemented without having to look any further.  Also, when the members of the abstract class are declared as abstract the IDE can generate method stubs for you automatically!  That does not happen if they are declared as virtual.

    Mark the best replies as answers. Fooling computers since 1971.

  • RELEVANCY SCORE 3.32

    DB:3.32:Interface And Abstract Class c3


    why we have constructor for abstract class and not for interface,

    DB:3.32:Interface And Abstract Class c3

    http://forum.java.sun.com/thread.jspa?messageID=10174604

    Double your pleasure or not!

  • RELEVANCY SCORE 3.32

    DB:3.32:Can Interface Extend Abstract Class? k3


    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 ?

    DB:3.32:Can Interface Extend Abstract Class? k3

    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

    ~

  • RELEVANCY SCORE 3.32

    DB:3.32:Abstract Class Implementation Dos Prompt c9


    Hello everyone,
    Good day! Anyone knows how to implement or use abstract class to another class. Pls.... help me. I'm still a novice programmer. Program like Bank Account with a abstract class named 'Account' and an another class 'Savings' extends the abstract class and also the third class named 'TimeDeposit' something like it.

    DB:3.32:Abstract Class Implementation Dos Prompt c9

    Hello everyone,
    Good day! Anyone knows how to implement or
    use abstract class to another class. Pls.... help
    me. I'm still a novice programmer. Program like Bank
    Account with a abstract class named 'Account' and an
    another class 'Savings' extends the abstract class
    and also the third class named 'TimeDeposit'
    something like it.One thing to remember is that your class has to include code for all methods that are marked abstract in the abstract class you are extending; and if you don't want anyone else extending your class, you should make it final. You should also check the abstract class's constructors to see if you need to call a particular one when you are constructing your class. If you do, you'll need to call super(...) in your class's constructor, and it should be the first statement.

  • RELEVANCY SCORE 3.31

    DB:3.31:Abstract Classes And Methods m3


    Is it legal or possible to implement a partial abstract class?

    For example:

    abstract class abclass{

    abstract void abmethod1(){}

    abstract void abmethod2(){}

    }

    final class ficlass extends abclass{

    //providing implementation for method abmethod1

    void abmethod1(){ //....

    return;
    }
    }
    // abmethod2 is not implemented in the class.

    Please provide some explantion if it can or cann't be done

    Thank you

    DB:3.31:Abstract Classes And Methods m3

    Thanks for the advice thomas.behr, but have no access to JDK right now, Hence decided to get some ideas from the forum.

  • RELEVANCY SCORE 3.31

    DB:3.31:Abstract Class 8m


    Hello,

    May I ask, can a class be considered abstract if there is no abstract method in it?

    If yes, then what purpose does this abstract class serve?

    Thank you.

    DB:3.31:Abstract Class 8m

    Hello,

    May I ask, can a class be considered abstract if there is no abstract method in it?

    If yes, then what purpose does this abstract class serve?

    Thank you.

  • RELEVANCY SCORE 3.30

    DB:3.30:Abstract Class dp


    Hi all,
    In a Abstract Class there is no Abstract methods only have non abstract methods. What is the use of this Abastract Class. If anybody know pls help me.

    DB:3.30:Abstract Class dp

    I wrote an abstract class recently that provided a set of methods which are common to a bunch of subclasses I wanted to write. However, the abstract class is useless on its own so I made it abstract to make it clear that there's no use instantiating it.

  • RELEVANCY SCORE 3.30

    DB:3.30:Abstract Class And Interfaces jf


    Hi,

    In which senarios, we can choose abstract class and interfaces

    Thanks

    DB:3.30:Abstract Class And Interfaces jf

    Hi,

    The most important scenario of deciding when to use Abstract Class or an Interface comes by trying to establish an IS-A relationship (abstract class) or CAN-DO relationship (Interface) is found between the related objects.

    1. e.g.
    A "Manager" IS AN "Employee" and a "SoftwareEngineer" IS ALSO AN "Employee"
    so for this relationship we can create an "Employee" Abstract class and the other classes "Manager" and "SoftwareEngineer" should derive from it and may provide their own implementations...........

    2. e.g.
    There will an annual appraisal for all types of Employees in an Organization. so, all employees must establish a certain kind of contract to fulfill for Appraisal which is done by an "IAppraisal" interface which has 2 methods - viz. a). public void IncreaseGrade();
    b). public void IncreaseSalary(double percentage);

    Hope this clarifies the scenario.

    Other aspects to decide are Versioning and Ease of Use between the 2.

    For more: pl. refer Applied .Net Framework book by Jeffry Richter

  • RELEVANCY SCORE 3.30

    DB:3.30:Abstract Classes a7


    Is it possible for an abstract class to have both abstract methods and non-abstract methods?

    public abstract class Person
    {
    private String name;

    public Person(String n)
    { name = n;}

    public String getName()
    {return name;}

    public abstract String getAddress();

    }And can a non-abstract class have abstract methods?

    DB:3.30:Abstract Classes a7

    An abstract class can have both abstract methods and non abstract method i,e the regular methods , but a non abstract class cannot have abstract methods. from this what we get is that its a must to have the class as abstract whenever you have a abstract method in it.

    if u add an abstract method in a simple class it will throw a error saying that u can only define an abstract metod in an abstract class.

  • RELEVANCY SCORE 3.30

    DB:3.30:Thread zj


    Is thread is abstract class????

    DB:3.30:Thread zj

    What does the javadoc say about [Thread ^javadoc^|http://java.sun.com/javase/6/docs/api/java/lang/Thread.html]?

  • RELEVANCY SCORE 3.30

    DB:3.30:Regarding The Abstract And Interface km


    hai,
    I am new to java programming

    I want to difference between abstract interface,interface and abstract class

    public abstract interface Test{}

    public interface Test{}

    public abstract class Test{}

    which kind of situations use the above interfaces and abstract classes

    It would be helpfull if explain with example....

    Thanks

    DB:3.30:Regarding The Abstract And Interface km

    shashikumar, please don't multipost and don't use the browser's back button to edit your post. This creates multiple posts. I've removed the other thread you started a minute after this one.

    db

  • RELEVANCY SCORE 3.30

    DB:3.30:Difference Between Abstract Class And Interface ca


    Hi everyone,

    CAn anyone explain why the following happen????

    --------------------------------------------------------------------------------
    Abstract class can have a constructor, Interface cannot.
    Abstract class can have static methods, Interface cannot.
    --------------------------------------------------------------------------------

  • RELEVANCY SCORE 3.30

    DB:3.30:From Abstract Class To Public Class 99


    I am developing a editor base application...wondering that how to cancel the abstract class and put all the abstract class methods into the public class..?? thanks

    DB:3.30:From Abstract Class To Public Class 99

    Is this a C++ question? If so, you should post it in the C++ forum. If it is a Java question, post in the Java forum.

    In either case, please make your question more specific. It sounds like all you have to do is copy the functions from the abstract class to the derived class, remove the dependency on the abstract class, and delete the abstract class from the source code. Presumably that is not what you are asking.

  • RELEVANCY SCORE 3.30

    DB:3.30:Where We Are Using Abstract Class With Out Abstract Method p7


    Why we need a abstract Class with out Abstract method?

  • RELEVANCY SCORE 3.30

    DB:3.30:Interface Vs Abstract Class sa


    when would you create an interface as opposed to an abstract class?

    DB:3.30:Interface Vs Abstract Class sa

    An interface solves the problem of multiple inheritance in Java. A class can only extend from one other class, but can implement multiple interfaces. I link to think of extending in a vertical fashion ( among a class hierarchy ), and interfaces in a horizontal fashion ( across classes that may have nothing in common ).

  • RELEVANCY SCORE 3.30

    DB:3.30:Mdb Abstract Base Class And Ejb3 Annotations 1k



    I have following scenario where my MDB class extends an abstract class which implements the MessageListener interface.
    public abstract class MDBBase implements MessageListener {
    public void onMessage(Message message) {
    ....
    processJob(some-params)
    }
    public abstract void processJob (some-params);
    }

    public class MyMDB extends MDBBase {
    public abstract void processJob (some-params) {

    }
    }

    DB:3.30:Mdb Abstract Base Class And Ejb3 Annotations 1k


    I have following scenario where my MDB class extends an abstract class which implements the MessageListener interface.
    public abstract class MDBBase implements MessageListener {
    public void onMessage(Message message) {
    ....
    processJob(some-params)
    }
    public abstract void processJob (some-params);
    }

    public class MyMDB extends MDBBase {
    public abstract void processJob (some-params) {

    }
    }

  • RELEVANCY SCORE 3.29

    DB:3.29:Jsp Taglibrary... 8m


    Hi Everyone,
    I have a doubt in how lifecycle of taglib works...

    public abstract void setPageContext(javax.servlet.jsp.PageContext);
    public abstract void setParent(javax.servlet.jsp.tagext.Tag);
    public abstract javax.servlet.jsp.tagext.Tag getParent();
    public abstract int doStartTag() throws javax.servlet.jsp.JspException;
    public abstract int doEndTag() throws javax.servlet.jsp.JspException;
    public abstract void release();

    Above is the sequence in which methods are called.

    THIS IS MY JSP PAGE

    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    HTML
    HEAD

    %@ taglib uri="cs6386-taglib.tld" prefix="cs6386" %
    TITLEcs6386:first_tag //TITLE
    /HEAD
    BODY
    H1cs6386:first_tag //H1
    cs6386:second_tag /
    /BODY
    /HTML

    My question is
    IN THE ABOVE PROGRAM I HAVE CALLED 3 TIMES THE TAG CLASS. SO EACH AND EVERYTIME IT WILL CALL doSTARTTAG() METHOD.IS THIS RELATED TO CREATING NEW INSTANCE...SO IF I DIDN'T CODE doENDTAG() IS IT GOING TO BE A PROBLEM..OR HOW IT EXCATLY WORKS...

    THANX IN ADVANCE...

    SENTHIL

    DB:3.29:Jsp Taglibrary... 8m

    I describe the tag handler lifecycle and what you need to be aware of in an article about JSP 1.2 on the ONJava.com site:

    http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html

    I'm pretty sure the "Lifecycle" section at the end answers your questions.

  • RELEVANCY SCORE 3.29

    DB:3.29:Instatiating An Abstract Class a3


    Hi all,

    As far as my knowledge goes i know that an abstract cannot be instantiated.

    With respect to the code given below:

    AbstractAction is an Abstract class but we are using the new keyword which is nothing but instantiating an object of AbstractAction class.
    Kindly clarify my doubt

    AbstractAction fontChangeAction = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
    fontChangeAction();
    }

    };

    DB:3.29:Instatiating An Abstract Class a3

    Well, it's not as if your explanation was particullary detailed ... uhm ...
    ok, I'll just go sit in my old-sods-chair in that corner over there, ok?Sure, go ahead but don't fall asleep grandpa, otherwise you're unable
    to sleep tonight ;-)

    kind regards,

    Jos (--- speedy)

  • RELEVANCY SCORE 3.29

    DB:3.29:Interface And Abstract Class dc


    why we have constructor for abstract class and not for interface,

    DB:3.29:Interface And Abstract Class dc

    Simpler reason: interfaces have no implementation. Period.

  • RELEVANCY SCORE 3.29

    DB:3.29:Re: Abstract Class Vs Interface f7


    rryrtyrt wrote:
    The doubt i have is that both represents nearly thethere is no doubt, only do!

    same and why the hell java supports both. It seems
    like ambiguity to me.look again.

    For example i can have only abstract class and do all
    the things that can be done with interface. then why
    this ambiguity.there is no ambiguity, only your misunderstanding of basic concepts.

    DB:3.29:Re: Abstract Class Vs Interface f7

    malcolmmc wrote:
    uj_ wrote:
    What's a contract? -:)A promise to perform certain functions given certain raw materials.

    Don't classes, interfaces and enums all define contracts?No, they fulfill contracts (often more than one).Well, you said contract is supposed to explain or describe something. What does it explain or describe?

    Is a type a contract or is an interface a contract or both or what?

  • RELEVANCY SCORE 3.29

    DB:3.29:Public Abstract Interface Filterconfig pf


    public abstract interface FilterConfig

    what is this class actually . is it abstract class or interface?

    DB:3.29:Public Abstract Interface Filterconfig pf

    interfaces are abstract because you cannot
    instantiate them.

    like you cant instantiate a abstract class.It's the other way around. You cannot instantiate them because they're abstract. Only what's fully concrete can be instantiated.