Polymorphism and inheritance

Just want to make sure I have a few things straight:
If I extend a full class, I'm demonstrating inheritance.
If I extend an abstract class (as a result, I need to override the abstract methods to provide implementations) I'm demonstrating polymorphism, though any class variables from the abstract class are INHERITED by my new class.
If I implement an interface, I'm exercising polymorphism.
Am I correct on all fronts?

Normally from an OO perspective there are twotypes
of polymorphism:-I've always found the classification of polymorphism
into static vs. dynamic kind of stupid. What does itWell its a free country, you have every right to feel that way.
matter whether methods are bound at compiletime or at
runtime? It's an implementation detail of little
importance. This classification doesn't offer anyI personally however found this particular detail of significant importance in how the different patterns work. However for somebody more interested in syntax than the semantics, yes it is of little importance.
deeper understanding of the difference between method
overloading and method overriding. The former is
bound at compiletime and the latter at runtime. So
what? But it's good chanting material of course -:)

Similar Messages

  • First Try with JE BDB - Indexes and Inheritance troubles... (FIXED)

    Hi Mark,
    Mark wrote:
    Hi, I'm a newbie here trying some stuff on JE BDB. And now I'm having
    I am happy to help you with this, but I'll have to ask you to re-post this question to the BDB JE forum, which is...
    Sorry for the mistake. I know now that here is the place to post my doubts.
    I'm really interested in JE BDB product. I think it is fantastic!
    Regarding my first post about "Indexes and Inheritance" on JE BDB, I found out the fix for that and actually, it wasn't about "Indexes and Inheritance" but "*Inheritance and Sequence*" because I have my "@Persistent public abstract class AbstractEntity" with a "@PrimaryKey(sequence = "ID_SEQ") private Long id" property.
    This class is extended by all my business classes (@Entity Employee and @Entity Department) so that my business classes have their PrimaryKey autoincremented by the sequence.
    But, all my business classes have the same Sequence Name: "ID_SEQ" then, when I start running my JE BDB at first time, I start saving 3 new Department objects and the sequence for these department objects star with "#1" and finishes with #3.
    Then I continue saving Employee objects (here was the problem) I thought that my next Sequence number could be #4 but actually it was #101 so when I tried to save my very first Employee, I set the property "managerId=null" since this employee is the Manager, then, when I tried to save my second Employee who is working under the first one (the manager employee), I got the following exception message:
    TryingJEBDBApp DatabaseExcaption: com.sleepycat.je.ForeignConstraintException: (JE 4.0.71) Secondary persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee#*managerId*
    foreign key not allowed: it is not present in the foreign database
    persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee
    The solution:
    I fixed it modifying the managerId value from "4" to "101" and it works now!
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...
    Have you any good material about these topics, perhaps a link where I can find more detailed information on these?
    Thanks in advance Mark, thanks for your attention on this and I will post more doubts in the future for sure ;0)
    Regards,
    Diego

    Hi Diego,
    I fixed it modifying the managerId value from "4" to "101" and it works now!I'm glad you found the problem. It is usually best to get the assigned ID from the entity object after you call put(), and then use that value to fill in related fields in other entities. The primary key field (assigned from the sequence) is set by the put() method.
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...Have you any good material about these topics, perhaps a link where I can find more detailed information on these? >
    To find documentation, start at the first message in the forum, the Welcome message:
    http://forums.oracle.com/forums/ann.jspa?annID=250
    This refers to the main JE doc page, the JE FAQ and a white paper on DPL queries. The FAQ has a section on the DPL, which refers to the javadoc. The DPL javadoc has lots of info on using cursors along with indexes (see EntityIndex, PrimaryIndex, SecondaryIndex). The white paper will be useful to you if you're accustomed to using SQL.
    I don't know of any doc on sequences other than the javadoc:
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/PrimaryKey.html#sequence()
    This doc will point you to info on configuring the sequence, if that's what you're interested in.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • +, - button and inherited tick box is in disabled mode for account assignme

    In the attribute tab of org structure (PPOMA_BBP), we are not getting +, - button and inherited tick box is in disabled mode for account assignment category (attribute is KNT).
    We want to enter two values for the account assignment category with inherited tick box (ticked).
    Please suggest me how to get the +, - and inherited tick box (ticked) for the account assignment.
    Regards.

    Hi Imam,
    Unde attributes
    You will find one Application Toolbar...
    Overview, Select Attribute, Check Entries,Insert line,Delete line..
    So under All values you will find AcctAssigCat, Exculded, Default, Inheried
    Select the row and click on Insert Line, now you should be able to insert the new acct Assignment category
    rg
    sam

  • Generic and Inheritance, how to use them together?

    Hi guys, I am trynig to design some components, and they will use both Generics and Inheritance.
    Basically I have a class
    public class GModel <C>{
        protected C data;
        public C getData(){return data;}
    }//And its subclass
    public class ABCModel <C> extends GModel{
    }//On my guess, when I do
    ABCModel abcModel = new ABCModel<MyObject>();The data attribute should be from MyObject type, is it right?
    So, usign the netbeans when I do
    MyObject obj = abcModel.getData();I should not use any casting, since the generics would tell that return object from getDta would be the MyObject.
    Is this right? If yes; did someone try to do that on netbeans?
    Thanks and Regards

    public class GModel <C>{
    public class ABCModel <C> extends GModel{public class ABCModel <C> extends GModel<C>{
    ABCModel abcModel = new ABCModel<MyObject>();ABCModel<MyObject> abcModel = new ABCModel<MyObject>();

  • Exact difference betwteen aggregation and Inheritance with example

    hi everybody
    Just I got some doubt regarding the difference betwteen aggregation and Inheritance and where we can differntiate the use of each other. I am little bit confused with the two usages when refering to objects.
    Thank you

    ramsy wrote:
    hi everybody
    Just I got some doubt regarding the difference betwteen aggregation and Inheritance and where we can differntiate the use of each other. I am little bit confused with the two usages when refering to objects.
    Thank youIt's the difference between the "is-a" and "has-a" relationship. A Car is-a Vehicle. A Car has-a Engine.

  • [svn] 2703: Fixes for bad links in seeTag and inheritance link.

    Revision: 2703
    Author: [email protected]
    Date: 2008-08-01 08:45:08 -0700 (Fri, 01 Aug 2008)
    Log Message:
    Fixes for bad links in seeTag and inheritance link.
    @seeTag was causing duplicate entries for package name in the array - which was causing a bad link..
    Bugs: SDK-9440, SDK-14265, SDK-12745
    QA: Yes
    Reviewed by: Paul
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-9440
    http://bugs.adobe.com/jira/browse/SDK-14265
    http://bugs.adobe.com/jira/browse/SDK-12745
    Modified Paths:
    flex/sdk/trunk/modules/compiler/asdoc/asDocHelper.as

    Revision: 2703
    Author: [email protected]
    Date: 2008-08-01 08:45:08 -0700 (Fri, 01 Aug 2008)
    Log Message:
    Fixes for bad links in seeTag and inheritance link.
    @seeTag was causing duplicate entries for package name in the array - which was causing a bad link..
    Bugs: SDK-9440, SDK-14265, SDK-12745
    QA: Yes
    Reviewed by: Paul
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-9440
    http://bugs.adobe.com/jira/browse/SDK-14265
    http://bugs.adobe.com/jira/browse/SDK-12745
    Modified Paths:
    flex/sdk/trunk/modules/compiler/asdoc/asDocHelper.as

  • Spatial index on table with object-column (and inheritance)

    Hi!
    Is it possible to create a spatial index on a table with an object-column (and inheritance) like this:
    CREATE OR REPLACE TYPE feature_type AS OBJECT (
    shape MDSYS.SDO_GEOMETRY
    ) NOT FINAL;
    CREATE OR REPLACE TYPE building_type UNDER feature_type (
    name VARCHAR2(50)
    CREATE TABLE features ( no NUMBER PRIMARY KEY, feature feature_type);
    [...] user_sdo_geom_metadata [...]
    Then
    CREATE INDEX features_idx ON features(feature.shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    throws:
    ORA-01418: specified index does not exist
    Curious! :)
    If I define feature_type with "NOT FINAL" option but without subtypes, I get (create index):
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01460: unimplemented or unreasonable conversion requested
    So I think besides object tables also inheritance isn't supported whith oracle spatial!?
    Thanks,
    Michael
    ps:
    We use Oracle9i Enterprise Edition Release 9.0.1.4.0 / Linux.
    Solves Oracle9i 9.2 this problems?

    Hi
    You'll need to be on 9.2 to do this....
    Dom

  • Polymorphism and JSF

    I was wondering if anyone can take a look at my blog entry about polymorphism and JSF.
    http://www.evolutionnext.com/blog/2005/03/07/1110236621000.html
    I would like to see what input any of you may have.

    absctract class A
    method1();
    class B extends A
    method1( ){ }// overrides, polymorphic method
    method2( ) {}// non-polymorphic method
    class C extends A
    method1( ){ }// overrides, polymorphic method
    method3( ) {}// non-polymorphic method
    class Test
    public static void main(String[] args )
    A a = new B();
    // only polymorphic method can be called
    a.method1();// called from B class
    // we can't call a.method2(); b/c its a non-polymorphic, for that we need full control to use casting
    B b = (B)a;
    b.method2();
    I agree with schapel's point of view.
    Taqi

  • Private attributes and Inheritance.

    I have a question regarding 'private attributes and inheritance'.
    If I have a class that will be extended by other classes,(basically
    this will act as a BASE class ),then why do I need to define
    any attribute private to this base class.?
    If I define an attribute as private in the base class,then the subclass cannot access
    this attribute.Right?
    1) Why define a private attribute in the base class ?
    2) When can a situation arise whereby the base class attribute is defined
    as 'private' and the base class is also extensible?

    If I define an attribute as private in the base
    class,then the subclass cannot access
    this attribute.Right?Right. A simple example would tell you this.
    >
    1) Why define a private attribute in the base class?Because information hiding and encapsulation are always good things, even between super and sub classes.
    >
    2) When can a situation arise whereby the base class attribute is defined
    as 'private' and the base class is also extensible?This question makes no sense whatsoever. A base class is extensible, unless it is marked as final, whether or not it's got private data members.
    Objects usually have private state and public interfaces. The idea is that clients of a class, even subclasses, should only access the private state thorugh the public interface. So if you've designed your classes properly you shouldn't need to access that private state.
    If you do, you can always provide get/set methods.
    OR declare the data members as protected. That way they're package visible and available to subclasses.
    But private members do not make a class inextensible.
    %

  • What is Polymorphism and how is it being applied?

    Dear All
    I need to seek your help in finding out what is polymorphism and how is it being applied?
    Thank you.

    Thank You So Much For This Link!
    http://faculty.frostburg.edu/cosc/htracy/cosc390/LM7Polymorphism/PolymJava.html
    I Am FOREVER GRATEFUL!
    See Ya Later - I got some Homework To do!!!!!!!!!!
    Jason
    REALLY ITS GREAT AND EXACTLY WHAT I'M LOOKING FOR TO LEARN JAVA
    Anybody that's really wants to learn this stuff from home should check this out. A little hard to follow the format, but definately readable.
    Edited by: jasonwpalmer on Nov 4, 2007 1:42 PM

  • Polymorphism and Up-Casting diff???

    Plz tell me the diff between
    Polymorphism and Up-Casting
    i m so much confuse

    absctract class A
    method1();
    class B extends A
    method1( ){ }// overrides, polymorphic method
    method2( ) {}// non-polymorphic method
    class C extends A
    method1( ){ }// overrides, polymorphic method
    method3( ) {}// non-polymorphic method
    class Test
    public static void main(String[] args )
    A a = new B();
    // only polymorphic method can be called
    a.method1();// called from B class
    // we can't call a.method2(); b/c its a non-polymorphic, for that we need full control to use casting
    B b = (B)a;
    b.method2();
    I agree with schapel's point of view.
    Taqi

  • Imported and Inherited properties

    Hi ,
    Can anyone please explain me what are the imported and inherited properties in OCD?
    How are they created?

    You can try running following query in your instance.
    SELECT f.*
    FROM cz_xfr_fields f, cz_xfr_tables t
    WHERE t.order_seq=f.order_seq
    AND t.dst_table='CZ_PROPERTIES'
    AND f.xfr_group='IMPORT'
    AND t.xfr_group=f.xfr_group
    AND f.dst_field='DEF_VALUE';
    SELECT f.*
    FROM cz_xfr_fields f, cz_xfr_tables t
    WHERE t.order_seq=f.order_seq
    AND t.dst_table='CZ_PROPERTIES'
    AND f.xfr_group='IMPORT'
    AND t.xfr_group=f.xfr_group
    AND f.dst_field='PROPERTY_UNIT'
    If the NOUPDATE field returns value 1, then update it to 0 by preparing appropriate UPDATE query for it.

  • Abstract classes and inheritance

    I'm trying to do some simple inheritance but I'm a little stuck. Without giving too much away here's what I have (or am trying to have). I have an abstract "Test" class and a number of concrete classes that extend that abstract class. In my main method I have an array of Test objects. Each object in the array is a certain kind of "Test" and each one has its own way of doing most things but it doesn't make sense to have just a plain Test object because it is an abstraction. In my code I go through the array and execute a method, runTest(), for each Test in the array. However, my abstract Test class doesn't have a runTest() method b/c it will never get used and java complains. At runtime shouldn't java figure out, OK this is TestA, so go to TestA's runTest method (polymorphism?). What should I put in my runTest method in the abstract class? I know I can put anything there but what is standard?

    JFactor2004 wrote:
    ... Each object in the array is a certain kind of "Test" and each one has its own way of doing most things but it doesn't make sense to have just a plain Test object because it is an abstraction. In my code I go through the array and execute a method, runTest(), for each Test in the array. However, my abstract Test class doesn't have a runTest() method b/c it will never get used and java complains. If you want to instantiate the Test class
    you need to provide an implementation for the runTest() method,
    something like/*type*/ runTest() { throw new UnsupportedOperationException(); }

  • ADF BC: Polymorphism and relations

    Hi,
    I'm building an ADF 11g application. In our data model, we have a table that contains four different types of transactions, all with the same attributes (columns). One column contains the transaction type and is the discriminator column. We also have customers, and each customer can have different types of transactions. In the database there is a foreign key relation between customers and transactions.
    In the user interface, there is a separate screen for each type of transaction. We added each type of transaction as a separate View Usage in the application module and used View Criteria to show only transactions of one kind. But now we want to have some default values set on the transactions and the default values depend on the type of transaction. Since default values are set on Entity Objects, I thought I'd need Entity polymorphism to accomplish this. There is a section on this topic in the [Fusion Developers Guide|http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcadveo.htm#sm0327]. I figure I also need polymorphic view rows, [as described in another section of the dev guide|http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcadvvo.htm#sm0515].
    But what I can't find anywhere on the internet is how to use polymorphism with Entity Associations and View Links. I don't want to define links for every sub type. I'd think that it should be enough to define the assocation/link on the top level. But I can't find any documentation on this. Another thing is that it seems that there is no way to have an "abstract" Entity or View Object. We have four types of transactions, let's call them A, B, C and D. On the Entity side, I'd like to have an abstract TransactionEO and four concrete Transaction+X+EO's. (Where X is one of the four types.) But it seems ADF BC forces me to use one of the four types as the default type and use that default type as the super class. Am I missing something here?
    To summarize, I'd like the following questions to be answered:
    <ol><li>How to use polymorphism in conjunction with Entity Associations and/or View Links?</li>
    <li>Is it right that I have to use one of my discriminator values as a default and use that default on the super type? (IOW: Is it right that there cannot be an abstract super Entity?)
    </li>
    <li>I noticed that a search on "polymorphism" on this forum returned zero results. Does that say anything about how much polymorphism is used in real life projects?</li>
    </ol>
    Thanks in advance for any help!
    Best regards,
    Bart Kummel

    I'm building an ADF 11g application. In our data model, we have a table that contains four different types of transactions, all with the same attributes (columns). One column contains the transaction type and is the discriminator column. We also have customers, and each customer can have different types of transactions. In the database there is a foreign key relation between customers and transactions.If you want all types of customers to be related to all types of transactions, then:
    * Create a BaseCustomer EO, defining its CustomerType attribute as descriminator and leaving the default value NULL for that discriminator attribute. It is not important that any row in the CUSTOMER table actually have a NULL value for the discrminator.
    * Create a BaseTransaction EO, defining its TransactionType attribute as descriminator and leaving the default value NULL for that discriminator attribute
    * Associate them
    Then any subtypes of BaseCustomer and any subtypes of Customer inherit this association, and any common code/attributes that are relevant to all customers and all transactions can live in this base class. It's not formally marked as "abstract" in the metadata, but for all intents and purposes it is your abstract EO if there never exists any row in the CUSTOMER table with CustomerType of NULL or any row in the TRANSACTION table with TxnType of NULL.
    In the user interface, there is a separate screen for each type of transaction. We added each type of transaction as a separate View Usage in the application module and used View Criteria to show only transactions of one kind. But now we want to have some default values set on the transactions and the default values depend on the type of transaction. Since default values are set on Entity Objects, I thought I'd need Entity polymorphism to accomplish this. There is a section on this topic in the [Fusion Developers Guide|http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcadveo.htm#sm0327].
    You'll need a view object with polymorphic entity usages, and will need to use the CreateWithParameters built-in operation to supply the discriminator attribute value at row create time so the framework knows what EO subtype you'd like the new view row to have.
    I figure I also need polymorphic view rows, [as described in another section of the dev guide|http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcadvvo.htm#sm0515].
    You would typically need this if either of the following is true:
    * Different view row subtypes will be exposing different sets of attributes
    * Different view row subtypes will require different sets of exposed client custom methods (or subtype-specific implementations of common view row custom methods inherited from the base)
    In that case, you'd viewlink the base VO's together, and the subtype VO's inherit those view links.
    But what I can't find anywhere on the internet is how to use polymorphism with Entity Associations and View Links. I don't want to define links for every sub type. I'd think that it should be enough to define the assocation/link on the top level. But I can't find any documentation on this. Another thing is that it seems that there is no way to have an "abstract" Entity or View Object.I mentioned above the closest thing we have to an "abstract" EO or VO. A base component whose discriminator attribute default value never actually occurs in row data (I used NULL above, but it could be any non-occurring value)
    We have four types of transactions, let's call them A, B, C and D. On the Entity side, I'd like to have an abstract TransactionEO and four concrete Transaction+X+EO's. (Where X is one of the four types.) But it seems ADF BC forces me to use one of the four types as the default type and use that default type as the super class. Am I missing something here?See my suggestion above.
    Let us know if any other questions pop up trying to implement the suggestions above.

  • Logical Database PNPCE and inherited Sub Area

    Hi,
    I have asked this in the HR forum but no response......
    I have a report using Logical Database PNPCE to find some values from a couple of info types. When I select a unit (from the 'OrgStructure' button at the top of the screen), say 111, and all its sub-units with no selections in the selection screen, I get one person displayed. This is correct and this person is in a sub-unit 3 levels down (unit 333).
    I then added a selection to only display people in units with Personnel SubArea 'OTEC'. Now I get no results output. When I look in PPOME, I can see that unit 333 has Personnel SubArea 'OTEC' but it is inherited from '111'.
    In PP01, unit 111 has an Account Assignment entry (Info Type 1008) but 333 does not.
    Does anyone know how to report on this?
    Is there a flag somewhere that tells the LDB to check for inherited units?
    If not, any ideas if there is a function out there to find the superior unit for these sub-units?
    Thanks.

    Thanks,
    I am aware of that FM but how do I find the parent unit in a clever fashion?
    The structure could have multiple levels e.g.
    Unit 1 - Unit 2a - Unit3a......
           - Unit 2b
           - Unit 2c
    Unit 1 is the parent and all the below units inherit from it.
    The LDB is looping through an internal table with a list of the units. It finds Unit 1 but not the rest.
    So, when the LDB is looking for Unit 3a, how does it know that Unit 1 is the parent?
    If I use that FM, I think I would have to look for all units above it and see if there is an Info Type 1008 exists. Seems like a lot of processing for something that should be simple?
    Kroc.

Maybe you are looking for