Inheritance problem with parent class calling child class

I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
public abstract class A {
    protected void function1 ( ) { }
    protected void function2 () {
         //calls function1();
         function1();
public abstract class B extends A {
    protected void function1 ()  {
         // do stuff
public class C extends B {
    protected void function1 ()  {
        // do stuff
        super.function1 ();
}I have an object instance of class C created and its function2() is invoked.
My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
Edited by: crono77 on Jan 10, 2008 8:13 PM

Nevermind, i found my error :)

Similar Messages

  • Having problem with siri on calling someone

    Hi.. i'm having a problem with siri when calling someone..it says " i can't call using that number "
    Im from Mauritius, our mobile number having been migrated into 8-digits since 1 month. I'd turn off siri, reset setting.. its the same!
    whats wrong with that?

    i"m from Mauritius also having the same problem when calling someone using siri.
    i think its because, of the 8 digits number.

  • I got problem with volume of calls...its on max and i still can hear person on other side really bad...i got 4s

    i got problem with volume of calls...its on max and i still can hear person on other side really bad...i got 4s

    Did you fix the problem? I have the same problem and it has been pain in the neck.

  • Who else has a problem with parental controls enabled not being able to run Firefox on the Mac?

    Who else has a problem with parental controls enabled not being able to run Firefox on the Mac? (Any solutions?) (BTW. Chrome doesn't work either)

    Although FF4 is so nice I'm almost ready to ditch iGoogle!
    Please fix what appears to be an RSS/iGoogle issue with FF4...
    Gmail is fine, but titles dont show in most RSS feed gadgets and no stories, strangely, apart from this one:
    http://www.google.com.au/ig/directory?hl=en&url=www.google.com/ig/modules/builtin_news_technology.xml
    Which if you enter the last part of the url reports that
    "<Content type="html">
    This is a builtin module, so the UserPrefs and Content are ignored."
    Any ideas?

  • Problems with 3-way calls, merge calls?

    loving my iPhone but having problems with 3-way calling and merging calls. tried to be on one call and have another person call (from a regular land line) and it went straight to voicemail for them. in addition, was on a regular call and tried to add another call AND tried to merge, none of the above has worked. i know this is included in the calling plan.
    anyone having similar problems?

    Per the Apple note in the link below, "Note: While iPhone is actively transferring data over EDGE—downloading a webpage, for example—you may not be able to receive calls. Incoming calls may go to voicemail."
    Perhaps this is what was happening.
    http://docs.info.apple.com/article.html?artnum=305711

  • I just had problems with a game called call of duty 4, modern warfare.  I decided that if I deleted it, I could reinstall it, I could get it back to normal. After I deleted it,I went to to the appstore and went to purchases and accidentaly deleted it/help

    I just had problems with a game called call of duty 4, modern warfare.  I decided that if I deleted it, I could reinstall it, I could get it back to normal. After I deleted it,I went to to the appstore and went to purchases and accidentaly deleted it.  please help me!

    You have not deleted it from the purchases list, it is just hidden. To unhide an app, open the Mac App Store app, click the Account link in the Quick Links to the right of the pane and go to the iTunes in the Cloud section where you can manage hidden apps.

  • Problem with lazy initialization in inhereted class

    Hi. I have a strange problem. I have 2 classes CMRCommandInputPanel (view ) , class CommandInputFieldsModel (view's model) and 2 classes that inherets from them: CMRDerivitiveCommandInputPanel and DerivativeCommandInputFieldsModel.
    the Views looks like:
    public class FormPanel extends JPanel {
        protected AbstractFormDataModel mFormModel = null;
        public FormPanel(AbstractFormDataModel formModel) {
            super();
            initialize(formModel);
        private void initialize(AbstractFormDataModel formModel) {
            mFormModel = formModel;
    public class CMRCommandInputPanel extends FormPanel {
         public CMRCommandInputPanel(AbstractFormDataModel formModel) {
              super(formModel);
              initialize();
         private void initialize() {
              initLocalModels();
            JPanel mainPanel =  new JPanel () ;
             mainPanel.setLayout(new BorderLayout());
            mainPanel.add(getUpperButtonsPanel(), BorderLayout.NORTH);
            mainPanel.add(getFormPanel(), BorderLayout.CENTER);
            mainPanel.add(getDownButtonsPanelDefault(), BorderLayout.SOUTH);
            mainPanel.addMouseListener(new MouseAdapter(){
                public void mouseClicked(MouseEvent e) {
                     // set focus on the formPanel in order to set the entered value on mouse click.
                        getFormPanel().requestFocus();
            this.setLayout(new BorderLayout());
            this.add(mainPanel);
            this.setBorder(UIConstants.DEFAULT_PANEL_BORDER);
         protected CMRPanel getFormPanel() {
              if (mFormPanel == null) {
                    adding editable TextFields to the panel.
             return mFormPanel;
         protected void initLocalModels(){
              new CommandInputFieldsModel(mFormModel,this);
    public class CMRDerivitiveCommandInputPanel extends CMRCommandInputPanel {
         private JTitledTextField mRealizationPriceField = null;
         public CMRDerivitiveCommandInputPanel(AbstractFormDataModel formModel) {
              super(formModel);
    // override of  super method
         protected CMRPanel getFormPanel() {
              if (mFormPanel == null) {
                    adding super classes  editable TextFields to the panel and some new ones
              return mFormPanel;
         /* (non-Javadoc)
          * @see cmr.client.ui.CMRCommandInputPanel#initLocalModels()
         protected void initLocalModels() {
              new DerivativeCommandInputFieldsModel(mFormModel,this);
         public JTextField getRealizationDateField() {
              if (mRealizationDateField == null) {
                   mRealizationDateField = new JTextField();
              return mRealizationDateField;
    public class CommandInputFieldsModel extends AbstractFieldsDataModel {
         protected CMRCommonDataModel mFormModel = null;
         protected CMRCommandInputPanel mView = null;
         public CommandInputFieldsModel(CMRCommonDataModel data,CMRCommandInputPanel aView){
              mFormModel = data;
              mView = aView;
              mFormModel.registryModel(this,ExBaseDataController.META_KEY);
              mFormModel.registryModel(this,CompanyMessagesController.META_KEY);
              mFormModel.registryModel(this,DefaultFinancialValueController.META_KEY);
              mFormModel.registryModel(this,QuantityValueController.META_KEY);
              mFormModel.registryModel(this,RateForPercentController.META_KEY);
         /* (non-Javadoc)
          * @see cmr.client.ui.data.CMRUpdatable#updateData(java.lang.Object)
         public void updateData(Object aNewData) {
                updating relevant fields by using getters of View
    public class DerivativeCommandInputFieldsModel extends CommandInputFieldsModel {
         public DerivativeCommandInputFieldsModel(CMRCommonDataModel data,CMRDerivitiveCommandInputPanel aView){
              super(data,aView);
         /* (non-Javadoc)
          * @see cmr.client.ui.data.CMRUpdatable#updateData(java.lang.Object)
         public void updateData(Object aNewData) {
              if (aNewData instanceof RealizationData){
                   RealizationData realizationData =  (RealizationData)aNewData;
                   CMRDerivitiveCommandInputPanel theView = (CMRDerivitiveCommandInputPanel)mView;
                   theView.getRealizationDateField().setValue(realizationData.getRealizationDate());
                   theView.getRealizationPriceField().setValue(realizationData.getRealizationPrice());
              }else
                   super.updateData(aNewData);
    }The problem is , that when the field's getter of inhereted view's class is called from model for updating field,the fields are beeing initialized for second time. they simply somehow are equal to NULL again. I've checked reference to the view and it's the same,but only new fields still equals to NULL from model.
    is someone can help me with that?

    The only thing that springs to mind is that you're
    exporting the newly created fields model object in
    the superclass constructor (at least I assume that's
    what the registry calls do).
    That can cause problems, especially in a
    multi-threaded environment (though it's often
    tempting). Again there's a risk that the
    partly-initialized object may be used.
    Actually this is a bit of a weakness of Java as
    opposed to C++. In C++ a new object has the virtual
    method table set to the superclass VMT during
    superclass initialisation. In Java it acquires its
    ultimate class indentity immediately.
    You'd be safer to extract all that kind of stuff from
    the superclass constructor and have some kind of
    init() method called after the object was
    constructed.
    In fact whenever you see a new whose result
    you don't do anything with, then you should take it
    as a warning.thank you for your replies. ;) I've managed to solve this matter. Simply fully redefined my panel with fields in child-class and added to it's constructor local initialization() method as well, which creates UI of child-class. Even that I initialize UI twice, but all fields are initialized with "lazy initialization" , so there is only once NEW will be called. but there is something weird going in constructors with ovverwritten methods.

  • Problem with outer joins and the class indicator/discriminator

    Hello,
    I am having a problem defining a query in toplink (10.1.3.3).
    In the workbench, I have created a parent and 2 child descriptors. The parent is "AbstractValue", the children are "DefaultValue", classified by the discriminator 'DEF', and "OverrideValue", classified by 'OVR', both located in the same table.
    Another descriptor (containing a one-on-one mapping to both a "DefaultValue", and a "OverrideValue") needs to be queried for its 'value'.
    The way the query should act is: If an override value (row) exists, this one applies for that object. If an override doesn't exist, return the default value.
    The query then comes down to (as I have it now):
    builder.getAllowingNull("OverrideValue").getAllowingNull("value").ifNull(builder.get("DefaultValue").get("value")).equal(builder.getParameter(VALUE_PARAM));
    The problem is that toplink adds the distinction for the different kind of "values" in the where clause WITHOUT checking for null values e.g. it performs an outer join, but then still checks for the discriminator value thus
    ....t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND ...
    instead of
    ... LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR') ...
    This leads to the behaviour that the query returns ONLY the objects that have override and default values.
    An overview of the queries (simplified)
    Toplink, at the moment, returns only results if both override and default values exists:
    SELECT t1.id
    t1.def_id,
    t1.ovr_id
    FROM values t2,
    parameter t1,
    values t0
    WHERE nvl(t2.value, t0.value) = 15 AND
    t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND
    t1.def_id = t0.id AND t0.discriminator = 'DEF'
    Situation Wanted:
    SELECT t1.id
    t1.def_id,
    t1.ovr_id
    FROM parameter t1
    LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR')
    JOIN values t0 ON (t1.def_id = t0.id AND t0.discriminator = 'DEF')
    WHERE nvl(t2.value, t0.value) = 15
    Anyone know if there is some statement I am missing to allow an actual outer join on descriptors containing class indicators/discriminators? A possible rewrite?
    Thanks in advance,
    Rudy

    This is a bug in TopLink's outer join support for Oracle. Currently the outer join is put in the where clause, instead of the from clause, as we do on other platforms. You might be able to fix it by changing your OraclePlatform to return false for shouldPrintOuterJoinInWhereClause().
    Please log this bug on EclipseLink, or through Oracle technial support.
    There is a workaround using,
    descriptor.getInhertiancePolicy().setAlwaysUseOuterJoinForClassType(true);
    James : http://www.eclipselink.org

  • Problem with File Upload using SmartUpload class.

    Hello.
    I need to get a file from client browser. I have HTML form that has mixed data, parameters and files submitted to server. I looked through the forum messages and got the, recommended by many, SmartUpload class. The problem is: when I call SmartUpload.upload() method my system hangs. It takes forever to download a file that is 20Kb. Below is the code from my source:
    SmartUpload su = new SmartUpload();
    su.initialize(getServletConfig(), req, res);
    su.upload(); <--- It stops right here forever...
    Enumeration enum = su.getRequest().getParameterNames();
    I tried the com.oreilly.servlet.multipart.MultipartParser class, also mentioned in forum messages. I used exactly the same html page to submit the same file and other parameters. It worked just fine. The only reason I need SmartUpload class is because it has getParameterValues(�) method that returns String array of values.
    Do you have any idea what is going on? If you know how to get array of values and file(s) without using SmartUpload from a html page, please help me with it.
    Thank you for any suggestions.

    I looked at MultipartRequest class before but the problems is that it saves upload file directly to disk (push technology). I need to save this file into an XML database, using InputStream, (the upload file is normally xml document or an image).

  • Problem with constructors and using public classes

    Hi, I'm totally new to Java and I'm having a lot of problems with my program :(
    I have to create constructor which creates bool's array of adequate size to create a sieve of Eratosthenes (for 2 ->n).
    Then it has to create public method boolean prime(m) which returs true if the given number is prime and false if it's not prime.
    And then I have to create class with main function which chooses from the given arguments the maximum and creates for it the sieve
    (using the class which was created before) and returns if the arguments are prime or not.
    This is what I've written but of course it's messy and it doesn't work. Can anyone help with that?
    //part with a constructor
    public class ESieve {
      ESieve(int n) {
    boolean[] isPrime = new boolean[n+1];
    for (int i=2; i<=n; i++)
    isPrime=true;
    for(int i=2;i*i<n;i++){
    if(isPrime[i]){
    for(int j=i;i*j<=n;j++){
    isPrime[i*j]=false;}}}
    public static boolean Prime(int m)
    for(int i=0; i<=m; i++)
    if (isPrime[i]<2) return false;
    try
    m=Integer.parseInt(args[i]);
    catch (NumberFormatException ex)
    System.out.println(args[i] + " is not an integer");
    continue;
    if (isPrime[i]=true)
    System.out.println (isPrime[i] + " is prime");
    else
    System.out.println (isPrime[i] + " is not prime");
    //main
    public class ESieveTest{
    public static void main (String args[])
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    new ESieve(maximum);
    for(int i=0; i<args.length; i++)
    Prime(i);}

    I've made changes and now my code looks like this:
    public class ESieve {
      ESieve(int n) {
       sieve(n);
    public static boolean sieve(int n)
         boolean[] s = new boolean[n+1];
         for (int i=2; i<=n; i++)
    s=true;
    for(int i=2;i*i<n;i++){
    if(s[i]){
    for(int j=i;i*j<=n;j++){
    s[i*j]=false;}}}
    return s[n];}
    public static boolean prime(int m)
    if (m<2) return false;
    boolean x = sieve(m);
    if (x=true)
    System.out.println (m + " is prime");
    else
    System.out.println (m + " is not prime");
    return x;}
    //main
    public class ESieveTest{
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    public static void main (String[] args)
    int n; int i, j;
    for(i=0;i<=args.length;i++)
    n=Integer.parseInt(args[i]);
    int maximum=max(args[]);
    ESieve S = new ESieve(maximum);
    for(i=0; i<args.length; i++)
    S.prime(i);}
    It shows an error for main:
    {quote} ESieveTest.java:21: '.class' expected
    int maximum=max(args[]); {quote}
    Any suggestions how to fix it?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem with getState() method in Thread class

    Can anyone find out the problem with the given getState() method:
    System.out.println("The state of Thread 1: "+aThread.getState());
    The Error message is as follows:
    threadDemo.java:42: cannot resolve symbol
    symbol : method getState ()
    location: class incrementThread
    System.out.println("The state of Thread 1: "+aThread.getState())
    ^
    1 error

    the api doc shows Since: 1.5
    You do use Java 5...if not... it's not available.

  • Problems with getWidth() and getHeight() in class Canvas

    Hi,
    i am developing MIDlets with Sun Studio4 One Update1 (Mobile Edition). Here is a simple example Code for my Problem:
    class MyCanvas extends Canvas
        public void paint(Graphics g)
            //Clear the Display
            g.setColor(0,0,0); //black
            g.fillRect(0,0,getWidth(),getHeight());
    }If i try to execute the Program with the Default Color Phone emulator included with Suns WTK2.0, everything works fine. (Ive tried to print out the results of getWidth() and getHeight() on the console, everything ok, the Displays width and height is displayed.).
    The problem is, that any other emulator from WTK1.0.4_01 (included with Sun Studio4 ME) compiles and preverifies fine, but while running the application, the emulator quits with the following error:
    ALERT: No such method getWidth.()I
    Execution completed successfully
    Anyone has an idea?
    Thanks!!

    Hello,
    I'm having the exact same problem and I'd like to know what changes you made to your code to get it working. My class is not an inner class and is very much like yours and so follows the form:
    class MyCanvas extends Canvas{ 
    int element = getWidth()/10;
    public void paint(Graphics g) {        //Clear the Display  
    g.setColor(0,0,0); //black
    g.fillRect(0,0,getWidth(),getHeight());
    I am also using WTK104. I did not have this problem until I renamed my file. I carried the renaming throughout the rest of the file in a consistent fashion and I don't see any problems with it. Any help appreciated.

  • Problems with extension of generic abstract class

    Hello,
    I'm having some problems with the extension of a generic abstract class. The compiler tells me I have not implemented an abstract method but I think I have. I have defined the following interface/class hierarchy:
    public interface Mutator<T extends Individual<S>, S> {
         public void apply( T<S> ind );
    public abstract class AbstractMutator<T extends Individual<S>, S> implements Mutator<T, S> {
         public abstract void apply( T<S> ind );
    }Now I implement AbstractMutator as such:
    public class BinaryMutator extends AbstractMutator<StringIndividual<Integer>, Integer> {
         public void apply( StringIndividual<Integer> ind ) { ... }
    }The compiler says:
    BinaryMutator.java:3: ga.BinaryMutator is not abstract and does not override abstract method apply(ga.Individual<java.lang.Integer>) in ga.AbstractMutator
    Why does it say the signature of the abstract method is apply(Individual<Integer>) if I have typed the superclass as StringIndividual<Integer>?
    Thanks.

    Yes, but the abstract method takes an arg of type <T extends Individual>. So it takes an Individual or a subclass thereof, depending on how I parameterise the class, right? StringIndividual is a subclass of Individual. So if I specify T to be StringIndividual, doesn't the method then take an arg of type StringIndividual?

  • Problem with JDBC results calling simple stored procedure in VC 7.0

    Hi all,
    I am building a simple VC model which calls a stored procedure on a JDBC database. I have created the system in the portal, defined the alias and user mapping, the connection test is fine and the VC "find data" lists my bespoke stored procedure.
    The stored procedure is :
    CREATE PROCEDURE dbo.dt_getBieUsers
    AS
    select * from dbo.emailuserlink
    GO
    When I test it using query analyser, it returns 3 records each with the two fields I expect - user and email address.
    I drag the model onto the workspace in VC and create an input form ( with just a submit button ). i drag the result port out to create a table. This has no fields in it.
    I build and deploy as flex and the app runs, I click the submit button and SUCCESS! I get 3 records in my table each with 2 fields. The data is all correct. The problem with this is the fields are determined at runtime it seems.
    I go back to the table and add 2 columns "email" and "address".
    i build and deploy and run the app. Again I get 3 records, but this time the contents of all of the rows is not data, but "email" and "address". The data has been replaced by the header texts in all of the rows.
    Can anyone help? Why isn't the data being put in my columns as I would expect?
    I tried to build and deploy the app as Web Dynpro rather than Flex to see if it was a bug in Flex. The application starts but when I click the submit button to run the JDBC stored procedure I get a 500 Internal Server Error
    com.sap.tc.wd4vc.intapi.info.exception.WD4VCRuntimeException: No configuration is defined for the entry JDBCFunction
        at com.sap.tc.wd4vc.xglengine.XGLEngine.createComponentInternal(XGLEngine.java:559)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstanceFromUsage(XGLEngine.java:362)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstance(XGLEngine.java:329)
        at com.sap.tc.wd4vc.xglengine.wdp.InternalXGLEngine.getCompInstance(InternalXGLEngine.java:167)
        at com.sap.tc.wd4vc.xglengine.XGLEngineInterface.getCompInstance(XGLEngineInterface.java:165)
    The JDBC connection I am using has a connection URL of jdbc:sap:sqlserver://localhost;DatabaseName=BIEUSERS
    and a driver class of com.sap.portals.jdbc.sqlserver.SQLServerDriver
    Can anyone solve my wierd problems?
    Cheers
    Richard

    Hi Richard,
    After you drag and drop the data service, right click on it and choose "Test data service". Then click on "Execute" and after you see the result on the right, click on "Add fields" button (inside the same window). Now you'll see that the fields are on the tabel. This is required only for JDBC data services, since this data (how the resultset is built) is not know in DT and it needs to be run firest - then analysed and only then you have to add the fields to the table).
    Regards,
    Natty

  • Compiling a class calling another class

    Hi,
    I have a problem with running an applet.
    my applet contains a thread and calls another class.
    when i compile it with javac, it says "cannot resolve symbol class Compute" which is the name of the other class.
    thank you for your help.

    Hi friend,
    How you solved this problem? can u please explain me
    too...
    I've an error while compiling my java file. cannot
    resolve symbol : class Student.
    where my two java files are...
    StudentBean.java
    public class StudentBean
    public static void main(String args[])
    Student s = new Student();
    Student.java
    public class Student
    String id,name;
    public Student(String id,String name)
    this.id = id;
    this.name = name;
    Both are in the same folder, please help me out of it.
    Thanking you,
    Harshavardhan.I do not know about the symbol resolution. But you do not have a default constructor in Student which may be causing an issue with the compile.

Maybe you are looking for

  • Convert byte array to table of int

    [http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print|http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print] Hello friends. I'm pretty new with PL/SQL. I have code that run well on MSSQL and I want t

  • Check for null field

    I have a FormCalc script that checks to see if TextField1 == TextField 2 and if it does then set a value of 1, if they're not equal, then 0. However, the form is setting the value to 1 even though there is no entry in either field. I'm thinking I nee

  • How do I transfer contacts from my old Iphone 3g to my new Iphone 4

    Hi everyone! I've been using an iphone 3g (carrier locked) for the last 2 years and I've recently purchased an Iphone 4 (carrier locked). First thing I did, was activated the micro Sim through my carrier's website (thus deactiviting the old sim). But

  • LiveCycle 8  - Preview PDF

    I have just installed Adobe Professional version 8 and found that even though Acrobat reader (the pro version) is loading fine with documents either locally or through a browser, LiveCycle 8 will not allow the use of the Preview PDF in the view setti

  • How to replicate the dbremove operations?

    Hi, My application have two site in a group, and use replication. Each site has a map to remember the dbs that are opend. In the master site, we create and open the db, the replicate it to the client. The db in the client is opend passively when a re