Inheritance Issue - constructor

Okay, I hope you guys can help me out of this. I currently have an interface designed, with a class inheriting its information. Here is the sample code for reference:
ArrayStack
public class ArrayStack
    implements AnotherInterface
    public ArrayStack(int stacksize)
        stack = new String[stacksize];
    public boolean isFull()
        return top == stack.length;
}Now the problem arises when I want to create a new class which inherits the ArrayStack. Here is a sample code of what I have wrote up:
public class checkSize extends ArrayStack
    public checkSize()
}I'm just trying to get my head around inheritance, but this code keeps giving me the error "cannot find symbol - constructor". Can anyone point me to the right direction or tell me what I can do? Any help would be greatly appreciated!

Connex007 wrote:
Melanie_Green wrote:
So as suggested you can either call another constructor or you can create a default constructor in your superclass,Now that's where I'm getting confused on - what other constructor can I call?There is only one other constructor to call in the super class.
Remember that the first line of every constructor is either an explicit or implicit call to another constructor. If you do not explicitly call another constructor then super() is inserted during compile time, and the default constructor that has no parameters of the superclass is called.
Furthermore any class that does not explicitly extend another class, extends Object. So as I stated previously if the first line of the any constructor in this class is not a call to another constructor, then the compiler will insert super() which will invoke the default constructor of Object.
Now in your scenario you are using inheritance, you have a subclass extending a superclass. Note that you have not defined a default constructor in the super class, which for example is defined in Object. So inside your subclass, if you do not call another constructor on the first line, then again the compiler will insert a call to super(). The call to super() from the subclass is dependent on the superclass having defined a default no parameter constructor. However in your case the superclass does not have such a constructor defined. Therefore you are still required to instantiate every class in the inheritance tree, either explicitly or implicitly.
If you are still weary at this point, think of it this way. If A extends B extends C. When an object of type A is instantiated, a constructor of A then B then C is called so that C is instantiated first, then B, then A. This is reflective of instantiated in a top down method so that each subclass is instantiated correctly. Since A extends B, and B can potentially be instantiated in one or more ways, you still need to define how both A and B are instantiated.
So relating this back to your problem, what are all the possible ways in which your superclass can be instantiated? We can eliminate the default constructor and assume that we must specify on the first line of the constructor contained in the subclass that a call to a constructor in the subclass or superclass occurs. If we invoke a constructor in the same class, in the subclass, then either this constructor calls a constructor in the super class, or it calls a constructor that in turn will tinkle its way up to calling a constructor in the superclass.
Mel

Similar Messages

  • Link selectors and inheritance issue

    On playing with simple navigation elements, (2) in total, I find an inheritance issue I do not understand.
    The ul, ol declarations in Boilerplate not being ignored, or overruled, by the css settings that I want for styles, which I had thought carried more weight?
    I was surprised when Boilerplate “lists” selector ul and ol declarations were impacting in this way.
    My intention was to use Boilerplate link selectors for bottom “footer” nav menu, and style sheet selectors for the top horizontal menu.
    Since I’m just expanding knowledge base, I have jumped around quite a bit, so have not uploaded to remote server. Three code blocks contributing are as follows…
    ————————Begin top horizontal nav menu code————————————————
    /*Top navigation menu is styled in external main.css as follows:*/
    #nav ul {
      list-style-type: none;
      /* [disabled]width: 260px; */
      /* [disabled]display: inline-block; */
      /* [disabled]height: 40px; */
      /* [disabled]overflow: hidden; */
      margin: 0 auto;
    #nav li {
      float: left;
      border: solid thin red;
      margin: 0 2px;
    #nav a:link {
      display: block;
      width: auto;
      font-size: 0.8em;
      font-weight: bold;
      color: #00CCCC;
      text-align: center;
      padding: 0;
      margin: 2px;
      text-decoration: none;
      text-transform: uppercase;
    #nav a:visited {
      color: #99B5C1;
    #nav a:hover {
      color: #9FD5C6;
    #nav a:active {
      color: white;
    ————————————-—End top horizontal nav menu——————————
    —————————————Begin footer nav menu code—————————
    /*Bottom navigation menu, placed in div id="footer" declarations in Boilerplate as follows*/
    a {
      color: #78AAB3;
      text-decoration: none;
    a:visited {
      color: #009999;
    a:hover {
      color: #F06;
    a:focus { outline: thin dotted; }
    /* Improve readability when focused and hovered in all browsers: h5bp.com/h */
    a:hover, a:active {
      color: orange;
      outline: 0;
      text-align: center;
    ——————End footer nav menu code———————————
    On following DOM, found following declaration padding: 0 0 0 40px; seems to be inheriting
    SHOULDN’T THIS PADDING DECLARATION IN BOILERPLATE BE OVERRODE BY  CSS?
    ——————Begin Boilerplate code specifics—————————
    ul, ol {
      margin: 1em 0;
      padding: 0 0 0 40px;
    ——————End Boilerplate code specifics—————————

    Joh Fritz II,
    Thanks for quick response.
    To clarify, or expand, on my query; Knocking out the Boilerplate padding of 40px in ul, ol selector is what I want to happen. I want the top menu to be entirely directed by the external css, while allowing Boilerplate selectors for future in the lower, or footer, nav links to come.
    My goal is to have a minimal menu selection at top, than at bottom, in footer, a site map sort of simple links. Stripping it (index.html) down to a minimal footprint to gain as lean and fast loading a page as possible.
    This 40px seems to be affecting my ability to center the menu within the top menu (div element "nav") When I disable that declaration, I can see the menu (dw design split/view) correct to left 40px. Funny thing is, with "layout box model" checked under "visual aids," I can no longer actually see the padding on hover. I could prior, so something I've done led to that.
    Thus, the visual shift on "disable" of the Boilerplate padding declaration tells me the Boilerplate continues to affect that which I actually want to control with external css.
    Apologies if I present contextual information poorly here; I may just clear and create again, but would like to  actually understand how I got here on this particular issue. 

  • PA and PSA Inheritance issue from Org Unit

    Hi,
    I am trying to create an Org Unit with effective from today or a future date. When I do this, PA and PSA is not getting inherited for the newly created Org Unit.
    But when I create an Org Unit with effective from past date, this issue is not there and works fine perfectly.
    Note: The issue is there in the Development Client as of now. But there is no issue in quality. There was a recent patch that gets updated in Dev system. Not sure whether patch is an issue.
    Cheers
    Vijay

    hi vijay...
    would you tell me about your problem in bit details...
    i understand that if you create new org unit with existing org unit which already maintained with its PA and PSA assigned in Account Assignment tab then its never occur this problem..but if you create your org unit out side the remaining structure the you must assign PA and PSA for this specific
    Regards
    Bashir Ahmadani

  • DFS ACL Inheritance issue

    We have an interesting problem for the forums.  We have implemented Distributed File Services for managing our shares.
    SecurityGroupA has similar ACL assignments to FolderA and FolderB.
    SecurityGroupB has limited ACL assignments to FolderB.
    When a member of SecurityGroupA moves a file from FolderA to FolderB, the file does not not inherit from FolderB.  We believe the issue is the DFS link gets redirected, but since the file's physical location doesn't actually move so no ACL changes happen
    and SecurityGroupB cannot see the file.
    If we break folder inheritance, then reapply inheritance to all child objects, this "fixes" ACL assignments and SecurityGroupB can see the file.
    One process I am considering is enabling file auditing and using event log "file creation" to trigger an ACL refresh script.  That's about as far as I have got to developing the process, though.
    Has anybody with DFS implementations run into this?  If so, how did you address the ACL refresh?
    Thanks,
    CS

    Hi,
    I'm a little unclear about the structure but it should be the default behaviour of NTFS permission. Please see this article:
    http://support.microsoft.com/kb/310316
    Also it provided steps to change the NTFS permission behaviour.
    Meanwhile if both folders are located in same volume, maybe you can workaround this with putting one of them to another volume so permission will be refreshed by a move.
    If you have any feedback on our support, please send to [email protected]

  • Python inheritance issue

    I'm trying to expand the functionality of the ConfigParser class and it is not working as I would expect.  I wrote my own class, inherited ConfigParser.ConfigParser, and expected to have all of the ConfigParser methods available to routines that instantiate objects of my new class.    It is not working this way.
    I've done this with other classes with no issues.  Is there something about ConfigParser that could be causing an issue?
    I'd post code but there are a lot of lines that are somewhat relevant.  I'm looking for some insight at this point.
    Thanks!
    Last edited by TomB17 (2009-09-08 20:21:12)

    hard to say without some code/example
    (edit: maybe use a nopaste if you want to paste a sizable chunk of code)
    Last edited by cactus (2009-09-08 22:03:28)

  • Help with inheritance issue!

    Hello:
    I have this base class for creating short integers, there are 3 ways for constructing it:
    1-constructor receives any possible integer value (long) and if it's small enough, TInt2 is created.
    2-From a valid String representation of a short integer
    3-Reading the value from a DataInput
    As you will see, in all constructors I end calling ValidAssign method, which will determine if initial parameter is valid or not:
    import java.io.*;
    public class TInt2
        public short val=0;
        //Default constructor
        public TInt2 (){val=0;}
        //Create a TInt2 only if var fits in 2 bytes
        public TInt2 (long var)throws Exception 
            ValidAssign(var);
        //Create a TInt2 from a string representing it
        public TInt2 (String var)throws Exception
          this(Short.parseShort(var));
        //Create a TInt2 whose value is read from DataInput, default constructor will be called by java,
        // but ValidAssign will be called by Read(in)
        public TInt2 (DataInput in)throws Exception
           Read(in);
        //Read a short integer from DataInput
        public void Read(DataInput ar) throws Exception
           ValidAssign(ar.readShort());
        //Write TInt2 value to DataOutput
       public void Write(DataOutput ar) throws Exception
           ar.writeShort(val);
       //Validate that var is in range to fit in 2 bytes
       private void ValidAssign(long var)throws Exception
            if((var<Short.MIN_VALUE)||(var>=Short.MAX_VALUE))throw new Exception("TInt2 : "+var+"  must fit in 2 bytes  (-32k,32k)");
            val=(short)var;
    }Now, assume I want to derive a class from TInt2: This class has the only particularity that will create non-negative short integers:
    public class TIntP2 extends TInt2
        public TIntP2 (){super();}
        public TIntP2 (long var)throws Exception {ValidAssign(var);}
        public TIntP2 (String var)throws Exception {this(Short.parseShort(var));}   
        public TIntP2 (DataInput in)throws Exception {Read(in);}
        private void ValidAssign(long var)throws Exception
            if((var<0)||(var>=Short.MAX_VALUE))throw new Exception("TIntP2 : "+var+" must be inside [0,32k)");
            val=(short)var;       
    }Now, my problem is this: if I call TIntP2(DataInput in), TInt2.Read(in) is called, but I want TIntP2.ValidAssign to be called instead TInt2.ValidAssign (I mean, I want to call the subclassed ValidAssign from the superclass Read). But with this code that doesn't happen: ValidAssign method called is that from superclass. So should I implement Read(DataInput in) in subclassed TIntP2 in order to have TIntP2.ValidAssign called or is there any way to make Java call the overriden method? should I declare it protected instead public?
    Thanks!

    If you want the ValidAssign method to be inherited and called polymorphically, like all the other methods in that example, you have to declare it public. Or at least, not private.

  • Personnel subarea inheritance issue

    Hi,
    not sure if this is an abap or functional question, so I started here.
    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.

    Hi,
    I couldn't find a simple solution so have used the FM RH_CHECK_ACC_INPUT to get the parent org unit details.
    Thanks.

  • AS3 asdoc inheritance issue.

    Hi,
    I have an API that inherits flash.display.Sprite .When I try to generate the ASDocs for the API, The ASdoc shows that my class inherits from flash.display.Sprite, but doesnt link or there is no click-able link to the Sprite's ASDoc. Can anyone tell me what I am missing.
    The command I am using in my ant script is
    <target name="main" depends="clean, createTemp" description="generates the asdocs for the project">
      <java jar="${asdoc.jar}" dir="${FlexSDK.dir}/frameworks" fork="true" maxmemory="256m" failonerror="true">
         <arg line='-load-config "${flex-config.xml}"'/>
         <arg line='-source-path ${src.dir}'/>
         <arg line='-doc-sources ${src.dir}/com'/>
         <arg line='-output ${docs.dir}'/>
         <arg value='-library-path+=${FlexSDK.dir}/frameworks'/>
    Thanks in advance for your help.

    I just stumbled upon the same bug you did. The netstream pauses (or crashses) whenever I press the fullscreen button i've got sitting on the page. It happens in Firefox, Google Chrome, Apple Safari, but NOT INTERNET EXPLORER. How does that make any sense at all?! I'm running 10.0.22.87 on all the browsers so you'd think if it worked on one (which I would have bet wouldn't have worked out of all I tried) it would work on all. So i'm stumped and wondering if you found out anything. I appreciate it!

  • Inheritance issue

    Hi,the code below I wrote gives me error.
    class student {
         String name;
         public student(String _name){
              name=_name;
    class child extends student{
         String Id;
         public child(String _name,String id){
              Id=id;
              name=_name;
    }I get error cant' find symbol student();what mistake am i doing?

    If you don't have an explicit call to constructor of super class, compiler tries to add a call to default constructor of super class, which doesn't exist.
    I'd suggest you delegate the instantiation of name to super constructor since the attribute belongs to parent class anyway. This should work -
         public child(String _name,String id){
                    super(_name);
              Id=id;
         }

  • Why this simple inheritance issue occour

    public class A extends B
         private Object lock=null;
         public A()
              super();// super intiallized
    Err:          lock=super; //givin error on this statement
    i m getting on above Err statement Error is
    '.' expected at line 57 (57:28)
    why is so is it not possible to assign super class to some other class in subclass
    how to solve this problem .and why it occour
    i also try this statement as
    lock=(Object)super;
    but same error occours
    Thanks

    super doesn't work like you would expect it to in the case of assignment. super isn't a reference to an object, but rather a mechanism for accessing inherited methods or fields.
    Try using the following
    lock = super.clone();Cheers,
    Cypher

  • Inherited Class Constructors

    Im having a problem with some code.
    I have one class extend another and they have different (and exclusive)
    constructors so im getting a compile error (because i guess i cant
    do this). Here is some code:
    public class ClassA{
    public ClassA(int i){
    public class ClassB extends ClassA{
    public ClassB(){
    }The problem is neither should be able to be instantiated
    with the others constructor.
    Any advice on how to make this work?
    Its time for Battestar Galactica anyway!

    Thanks a lot. I really appreciate it.
    I wasnt aware that super() was called automatically.
    I googled "nullary constructor" and read up on it.
    I fixed the code by just putting
    super(3); into ClassB's constructor.

  • Class inheritance issues!

    Hello,
    I have this code working on one computer but it won't work on another.
    // - CPoint class
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class CPoint extends Object
       public double dX, dY, dHeight, dZ;
       public CPoint( double dNewX, double dNewY, double dNewHeight, double dNewZ )
          //Store coordinate values
          dX = dNewX;
          dY = dNewY;
          dHeight = dNewHeight;
          dZ = dNewZ;
    }this class compiles perfectly. However when I then compile this...
    // - PLine class
    public class PLine extends Object
       public CPoint cpoint[];
       public NewFile3 nFile3;
       double dX, dY, dHeight, dAngle, dZ;
       public PLine(String sNewzoneName, String sNewfileName, double dNewLLx, double dNewLLy, double dNewLLz)
         try
            //Call FileRead2 class
            nFile3 = new NewFile3(sNewzoneName, sNewfileName);
         catch (Exception exception)
            exception.printStackTrace();
         //Create array to store CPoint objects
         cpoint = new CPoint[nFile3.npCounter];
         dHeight = nFile3.dH + dNewLLz;
         dZ = dNewLLz;
         dAngle = nFile3.dAngle;
         for( int t=0; t<cpoint.length; t++)
            //Obtain values from FileRead2
            dX = nFile3.Points[t][0] + nFile3.dlX + dNewLLx;
            dY = nFile3.Points[t][1] + nFile3.dlY + dNewLLy;
            //Create an array of CPoint objects
            cpoint[t] = new CPoint( dX, dY, dHeight, dZ );
    }I get, amongst others, the following error...
    ".....C:\Documents and Settings\WalterOG\Desktop\New Folder\PLine.java:11: cannot resolve symbol
    symbol : class CPoint
    location: class PLine
    public CPoint cpoint[];
    It doesn't make sense because the software I'm using on both computers is the same except there maybe a newer version of Java on the machine that is giving the error???
    One other question, does Visual Studio 6 support swing? I'm not even using VS but I was just wondering??
    Anyone got any ideas??
    Cheers,
    wALLY!

    It would appear that you didn't put either class in a package. You will have to be careful that the compiler expects all your classes to be in the anonymous package. Are you using the javac command line compiler or some development environment to try to compile your code? The development environment may assume that your classes are supposed to be in some package, based on the directory path they are located under, and on your current project's properties in the IDE.
    If you are using javac, then you need to invoke it from the same directory that the .java files are located in. You can't, for instance, say "javac myDirectory" from the directory above where the source files are stored. In that case, javac would assume that your classes were in a package called "myDirectory" but they aren't so it wouldn't be able to find them.

  • Java OO inheritance issue

    Hello,
    I have a API written to provide service related implementation in which i have abstract class called com.api.XXXServiceInterface which needs to be implemented by every service provider and then deploy it in JNDI name space e.g.
    public class myServiceProvider implements com.api.XXXServiceInterface
    public void startService()
    bind(this) //This method will bind this class into JNDI
    while binding into JNDI, service provider will be binding his service class i.e. com.test.myServiceProvider which implements com.api.XXXServiceInterface from provided API
    Now in my platform when i bind to JNDI to find specific service provider's service i will get com.test.myServiceProvider class object and i am trying to type cast it to com.api.XXXServiceInterface but this type casting is throwing ClassCastException class not found com.test.myServiceProvider as my platform will be running somewhere else where i do not have service provider's class object but i will have its super interface class com.api.XXXServiceInterface where i want to do something like
    com.api.XXXServiceInterface service = (com.api.XXXServiceInterface)ctx.lookup("MerchantService");
    service.startService(); //to start service providers service
    How can I achieve this? Please provide me any suggestion and comments
    Thanks

    but basically this is not good code for two reasons:
    a) instanceof takes a looong time :x
    b) there are better ways:
    take advantage of the overriding/dynamical bindings in java:
    class A {
        public int getValue() { //could be declared abstract
            return 0;
    class B extends A {
        int bValue = 50;
        public int getValue() {
            return bValue;
    class C extends A {
        int cValue = 100;
        public int getValue() {
            return cValue;
    A myObject = SelectedObject;
    System.out.println(myObject.getValue()); //wil print 0 if Selected was an A-Object, 50 if it was an B-Object, 100 if it was an C-Object
    ...

  • Call function in a constructor

    Hello
    It is OK if I want to call a function inside a contructor
    For example:
    class A
    public A{
    function a();
    function a()
    Thank you
    sho

    I just found the chapter in Josh's book that covers this topic. I knew I read this a couple years ago.
    From: Effective Java by Joshua Bloch
    Chapter 4 - Item 15: Design and Document for Inheritance or else Prohibit it
    "There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or indirectly. If this rule is violated, it is likely that a program failure will result. The superclass constructor runs before the subclass constructor, so the overriding method in the subclass will get invoked before the subclass constructor has run. If the overriding method depends on any initialization performed by the subclass constructor, then the method will not behave as expected."

  • AD object security inheritance getting disabled

    Hi,
    I am observing few uses are having security inheritance issue and AD administrators are losing their permissions on these user objects.
    Inheritance is getting removed automatically after some time even after setting it manually as per below screenshot.
    Please if anyone can tell me on how to find the cause of this issue. Also, If I check advanced security on the parent OU, I am not getting the option to apply the inheritance on all child objects. Is there any way or command via which I can re-enable inheritance
    or apply permissions on all child objects under an OU ?
    Thank you in advance.
    Regards,
    J R Dash

    This is the behavior of protected groups, those users are members of one or more protected groups.
    The PDC role holder compares the ACL defined on each user object that is a
    member of a protected group with the ACL defined on the adminSDHolder object
    every sixty minutes.  If the ACL on the user object is different to the ACL
    on the adminSDHolder object, the ACL on the user object is reset to that of
    the adminSDHolder object.
    See the follow articles,
    Protected Groups and the adminSDHolder object:
    http://support.microsoft.com/?id=817433
    http://support.microsoft.com/?id=318180
    Enfo Zipper
    Christoffer Andersson – Principal Advisor
    http://blogs.chrisse.se - Directory Services Blog

Maybe you are looking for

  • Badi in ecc6.0

    screen in se18 and se19 in ECC6.0 is different from ECC5.0    so please guide me step by step to build badi in ecc6.0         rahul siemens

  • SAP Query: ABAP List Only

    hello friends, how do i hide the "Output format" box from the UI of my SAP query? i would just want a query that would automatically have an ABAP List output without users having to choose other layouts (meaning the "Output format" is not seen on the

  • Mail with Mountain Lion

    With Lion I was prompted to type in a password to access my mail. With ML it doesn't ask for a password. Is there a way that it will ask for a password before retrieving my mail?

  • How do i put one playlist on my ipod and not the entire library

    I have recently purchased the newest ipod nano and downloaded the newest itunes and I cannot seem to find out how to select one playlist to go on my ipod. I don't want the entire library but only 1 of the playlists. How do i do this? Thank you!

  • Help got error 34 when try to dowload trial

    when i try to download stuff like after effects it gives me error 34 can someone give me a step by step guide to fix this thanks