Constructor inheriting

Can we inherit a constructor of the base class in the derived class.
Please help.
Shravan

You can always write a constructor of your own, and call the super class constructor:
public Dummy(int dummy) {  // Constructor for class Dummy which
                            // extends a class with a constructor which takes one int
    super(dummy);
}/Kaj

Similar Messages

  • Constructor Inheritance Question

    Here's a quote from the Java Tutorials at http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html :
    "All classes have at least one constructor. If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor. This default constructor calls the class parent's no-argument constructor, or the Object constructor if the class has no other parent. If the parent has no constructor (Object does have one), the compiler will reject the program."
    In order to fully understand this concept, I created two classes: a ClassParent and a ClassChild.
    public class ClassParent
        public static void main(String[] args) {
           ClassParent tester = new ClassParent();
    public class ClassChild extends ClassParent
        public static void main(String[] args) {
            ClassChild child = new ClassChild();
    }Both classes compiled successfully, which raised the following question:
    I understand that the ClassParent default constructor calls the Object's no-argument constructor.
    Does the ClassChild also call the Object's constructor once it realizes that the ClassParent does not have a no-argument constructor?
    And a somewhat non-related question:
    Seeing how ClassParent calls Object's no-argument constructor if it does not have one of its own, does it also extend the Object class?
    Edit: After running the following code, I realized that the answer to my last question is yes:
    public class ClassParent
        public static void main(String[] args) {
           ClassParent tester = new ClassParent();
           boolean test = tester instanceof Object;
           System.out.println(test);
    }Edited by: youmefriend722 on May 26, 2008 1:54 PM

    youmefriend722 wrote:
    I think I'm getting a basic grasp now but want to make sure that I'm not misunderstanding anything.
    Constructor inheritance:
    If a no-argument constructor is invoked but one isn't declared in that class, the superclass's no-argument constructor will be invoked. Well, sort of. If you invoke a constructor that doesn't exist, you get an error. Keep in mind that the invocation and the constructor may both be automatically supplied by the compiler, and that the compiler won't automatically create a no-arg constructor for a class if you define any constructors for that class.
    So if you don't define any constructors in a class, then a no-arg one is created automatically (at compile time) and (at runtime) when you instantiate that class, that no-arg constructor will try to invoke the superclass's no-arg constructor.
    But suppose you do define a constructor, one that takes an argument. Then if you try to invoke a no-arg constructor on that class, you'll get an error, and the superclass's no-arg constructor won't be invoked (because the error happens first).
    If the superclass does not have a constructor, then the superclass's superclass's constructor will be invoked.No. That never happens. Every class has a constructor (although it might have permissions which make it inaccessible, which is a whole other issue we'll worry about later).
    If the superclass does have a constructor but doesn't have a no-argument constructor, then there will be a compile-time error.Only if you try to invoke the no-arg constructor, which might happen implicitly. For example, if you write a superclass with a 2-arg constructor, and you write a subclass with a 1-arg constructor, and the 1-arg subclass's constructor invokes the superclass's 2-arg constructor, then there's no problem, even though in this example, the superclass doesn't have a no-arg constructor.
    Constructors in general:
    In every constructor, the superclass's no-argument constructor will be invoked if the none of the superclass's constructors are explicitly invoked.Yeah, I think that's right.

  • Constructor / inheritance / encapsulation issue

    Please consider this code:
    public class Main {
      public static void main(String[] args) {  new BBB();  }
        public static class AAA {
            private int x;
            AAA() {  foo();  x = 123; }
            public void foo() { println("AAA::foo()"); }
        public static class BBB extends AAA {
            BBB() { super(); }
            public void foo() { println("BBB::foo()"); }
    }The result is that the constructor in AAA invokes BBB's foo(), which violates encapsulation. I would just like to ask:
    Invoking public/protected instance methods in the constructors of non-final classes is absolutely forbidden, right?
    I am not asking why that happens. Rather, I just want to confirm the answer is "yes", it is forbidden. Or, if there are cases when it is ok, I am interested in learning them. Doing more that initializing instance variables in a constructor seems intriguing. But doing so could create weird situations (as in AAA's constructor) where you can access the private variable "x" of AAA and then invoke the BBB's foo().
    ps: the "users online" and "guests online" forum statistics always equal zero.

    dpxqb wrote:
    abillconsl wrote:
    dpxqb wrote:
    Please consider this code:
    The result is that the constructor in AAA invokes BBB's foo(), which violates encapsulation.Why does it violate encapsulation? BBB is a subclass of AAA, not just any class.So I design class AAA.
    AAA's constructor requires that AAA's foo() be invoked to initialize.
    AAA cannot control the behavior of BBB.
    BBB subclasses AAA, and overrides foo().
    If BBB's foo() does not invoke super(), AAA cannot initialize and thus neither can BBB.
    I see more what you're talking about. Well first of all you don't have foo() invoking super() you have B() doing it - small point but worth getting straight. I never said, and didn't mean that your code was desireable BTW ... I said it's understandable and a good learning devise. Two other posters gave you good advice as to what to do about it. I'll give you another. make foo() private instead of public. There is no reason to show all your implementation code to everyone and good reasons not to. If foo() should not be called by anything but the ctor or AAA, then hide it. There is not reason that I can see to override that method either. AAA should be initialized only by AAA, and BBB by BBB. So you call foo instead aaaInitialize() and foo in BBB bbbinitialize.
    Further, in the AAA constructor, a private variable is accessed "x", and then in the next line a method of a subclass is invoked. This blurs the boundary between what is hidden by the super class and exposed by a subclass (breaking encapsulation).
    I would just like to ask:
    Invoking public/protected instance methods in the constructors of non-final classes is absolutely forbidden, right?No it's not forbidden at all.The super class looses the ability to initialize itself. It becomes dependent on subclass behavior which breaks encapsulation.
    I am not asking why that happens. Rather, I just want to confirm the answer is "yes", it is forbidden. Or, if there are cases when it is ok, I am interested in learning them.You should do a Topeka on the subject.ok.
    Doing more that initializing instance variables in a constructor seems intriguing.
    It's done all the time. For example, in the constructor you might all methods like: "createAndBuildGUI()", which would build the graphics part of a desktop app - instead of doing all that code directly in the one constr method. Just one example. IDE's like Eclipse do things like this.
    But doing so could create weird situations (as in AAA's constructor) where you can access the private variable "x" of AAA and then invoke the BBB's foo().This is not wierd - it's designed to work like this.I just don't get it. A super class should never be allowed to invoke subclass's methods. The super class has no idea what the subclass's methods would do, so how could this be a reliable way to code? A class that invokes protected/public methods in the constructor is fragile and breakable. A concrete class should always be able to initialize itself regardless of what subclasses do.
    As jschell hinted, I totally lost focus on what a "constructor" is suppose to do: just initialize the object and get it ready to roll, and nothing more. no behavior. thanks.

  • Extending a class, its constructor inherited ?

    class a extends JFrame
    xxxxxxxx
    public void a()
    xxxxxxxxxx
    class someclass
    a myA = new a();
    ================
    there is a constructor -> JFrame(String title) in JFrame.
    when i create an instance of this class a this way which extends JFrame, do i overwrite the constructor JFrame(String title) ? what if i want to have a constructor that i can use to create the instance of a this way ->
    a myA = new a("my title")
    how should i do it? and as for a good java programmer, what is the best and most efficient way ?
    thank you

    hi,
    class a extends JFrame
    xxxxxxxx
    public void a()
    super();
    public void a(String title)
    super(title);
    class someclass
    a myA = new a("My Title");
    Phil

  • Having a problem with inheritance and a constructor

    i have two classes, i'm just going to give the constructors anyway. I'm having trouble getting the CDImage constructor to inherit something from songs, I believe the instructions are missing something or the cs lab guy misinterpreted them.
    package songs;
    import java.text.*;
    public class Song implements Comparable {
        private int songLength;
        private String artistName;
        private String songName;
        public Song(int songLength, String artistNames, String songName) {
            this.songLength = songLength;
            this.artistName = artistNames;
            this.songName = songName;
        }These are the instructions that i beleive may be incorrect:
    Design a CDImage class to represent a music CD. The constructor takes three parameters: the title of the CD, the recording label, and the number of tracks on the CD. (Each track contains one song.) The CDImage class uses the Song class developed above and should contain methods to accomplish the following:package songs;
    import java.text.*;
    public class CDImage extends Song {
        private String title;
        private String label;
        private int numberTracks;
        private Song[] songs;
        public CDImage(String title, String label, int tracks){
        this.title = title;// this is the album name
        this.label = label;
        numberTracks = tracks;
        songs = new Song [numberTracks];
        }i know i need to use the super modifier under the constructor but how? because nothing in the constructor of the CDImage class refers directly to the constructor in the Song class
    thanks in advance.
    Message was edited by:
    kevin123

    you know whats funny, this project has to do with arrays of objects and not inheritance. We learned inheritance last week but the lab we are doing which is this, is for arrays of objects. sorry for the confusion lol. so you can completely ignore this, it actually has it in big bold letters at the top of the web page for the lab.

  • Inheritance Constructor error

    Hi guys, having a spot of bother with a constructor of a sub-class.
    What i am doing is making a super class... Person and a subclass... Administrator
    When i am coding my constructor for the administrator every inherited field constructs but my local one does not
    The error i get is on the constructor parameter, Cannot find symbol : constructor Person. class: Person
    I think it may be something to do with java not knowing what constructor to use
    Heres my code
    Personpublic abstract class Person{
        // TO DO
        // READ THE COMMENTS AND COMPLETE
        //Attributes
       public String name;
       public String address;
       public String sex;
       public int age;
           public Person(String name, String address, String sex, int age) {
            this.name = name;
            this.address = address;
            this.sex = sex;
            this.age = age;
        }Administrator
    public class Administrator extends Person {
        // Attributes
        private String type;
        // TO DO
        // READ THE COMMENTS AND COMPLETE
         * Constructor
         * @param name name of the administrator
         * @param address address of the administrator
         * @param gender sex of the administrator
         * @param age age of the administrator
         * @param type member type of the administrator
        public Administrator(String name, String address, String gender,
                int age, String type) {
            this.name=name;
            this.address=address;
            this.sex= gender;
            this.age=age;
            this.type=type;
        }

    If you don't explicity invoke a super constructor, the compiler inserts a call to the no-arg c'tor: super(); If your parent class does not have such a c'tor, that's an error. You'll need to add a call to
    super(name, age, gender);
    // or whatever parameters the parent's c'tor actually takesas the first line of your child class c'tor.

  • Constructors and Inheritance in Java

    Hi there,
    I'm going over access modifiers in Java from this website and noticed that the following output is displayed if you run the snippet of code.
    Cookie Class
    import javax.swing.*;
    public class Cookie {
         public Cookie() {
              System.out.println("Cookie constructor");
         protected void foo() {
              System.out.println("foo");
    }ChocolateChip class
    public class ChocolateChip extends Cookie {
         public ChocolateChip() {
              System.out.println("ChocolateChip constructor");
         public static void main(String[] args) {
              ChocolateChip x = new ChocolateChip();
              x.foo();
    }Output:
    Cookie constructor
    ChocolateChip constructor
    fooI've been told that constructors are never inherited in Java, so why is "Cookie constructor" still in the output? I know that ChocolateChip extends Cookie, but the Cookie constructor isn't enacted when the new ChocolateChip object is defined... or is it?
    If you can shed any light on this, I would greatly appreciate it.
    Many thanks!

    896602 wrote:
    I've been told that constructors are never inherited in JavaThat is correct. If they were inherited, that would mean that, just by virtue of Cookie having a c'tor with some particular signature, ChocoChip would also "automatically" have a c'tor with that same signature. However, that is not the case.
    , so why is "Cookie constructor" still in the outputBecause invoking a constructor always invokes the parent class's c'tor before any of our own c'tor's body executes, unless the first statement is this(...), to invoke some other c'tor of ours. If this is the case, eventually down the line, some c'tor of ours will not have an explicit this(...) call. It will either have an explicit super(...) call, or no call at all, which ends up leading to the compiler generating a call to super().
    Note that the ability to call super(...) does not mean that that c'tor was inherited.
    I know that ChocolateChip extends Cookie, but the Cookie constructor isn't enacted when the new ChocolateChip object is defined... or is it?Yes, it is. As I pointed out above, if we don't explicitly call this(...) or super(...), then a call to super() is inserted by the compiler.

  • Constructors in Inheritance.

    Hi,
    REPORT  Z_INHERITANCE_CONSTRUCTOR.
    CLASS demo DEFINITION.
      PUBLIC SECTION.
      CLASS-METHODS main.
      ENDCLASS.
    CLASS vessel DEFINITION.
      PUBLIC SECTION.
      METHODS : constructor IMPORTING i1 TYPE string
                                                                i2  TYPE string,
                         show_output.
      PROTECTED SECTION.
      DATA name TYPE string.
      DATA *** TYPE string.
      ENDCLASS.
    CLASS ship DEFINITION INHERITING FROM vessel.
      ENDCLASS.
    CLASS motorship DEFINITION INHERITING FROM ship.
      PUBLIC SECTION.
      METHODS : constructor IMPORTING i_name TYPE string
                                                                i_fuel_amount TYPE i.
      PRIVATE SECTION.
      DATA fuel_amount TYPE i.
      ENDCLASS.
    CLASS vessel IMPLEMENTATION.
      METHOD constructor .
        name = i1.
        *** =  i2.
      ENDMETHOD. "constructor
      METHOD show_output .
         DATA : name TYPE string,
                     *** TYPE string,
                     output type string.
                    name = me->name.
                    *** = me->***.
         CONCATENATE 'The Name is : ' name '& The *** is :' ***  into output.
         MESSAGE output TYPE 'I'.
      ENDMETHOD. "show_output
      ENDCLASS.
    CLASS motorship IMPLEMENTATION.
      METHOD constructor .
      super->constructor( i1 = 'Abhinab' i2 = 'M' ).
      fuel_amount = i_fuel_amount.
      ENDMETHOD. "constructor
      ENDCLASS.
    CLASS demo IMPLEMENTATION.
      METHOD main .
    DATA : o_vessel TYPE REF TO vessel,
            o_ship TYPE REF TO ship,
            o_motorship TYPE REF TO motorship.
    CREATE OBJECT : o_vessel EXPORTING i1 = 'Vivien'
                                                                        i2 = 'M',
                                    o_ship EXPORTING i1 = 'Sia'
                                                                    i2 = 'F',
                                    o_motorship EXPORTING i_fuel_amount = '1200'
                                                                              i_name = 'Eules'.
      ENDMETHOD. "main
      ENDCLASS.
      START-OF-SELECTION.
      demo=>main( ).
    In my code the method show_output doesn't get implemented,but when i place the same code of show_output  in the constructor method the code is getting executed.
    I am not able to figure out the reason behind this.
    can anybody please help me understand why is this happening??
    Regards,
    Abhinab Mishra

    The show_output method was never been called.
    o_vessel->show_output is required in the main method of demo.
    Silly Mistake.
    Regards,
    Abhinab Mishra

  • Help with constructors using inheritance

    hi,
    i am having trouble with contructors in inheritance.
    i have a class Seahorse extends Move extends Animal
    in animal class , i have this constructor .
    public class Animal() {
    public Animal (char print, int maxage, int speed) {
    this.print = print;
    this.maxage = maxage;
    this.speed = speed;
    public class Move extends Animal {
    public Move(char print, int maxage, int speed)
    super(print, maxage, speed); //do i even need this here? if i dont i
    //get an error in Seahorse class saying super() not found
    public class Seahorse extends Move {
    public Seahorse(char print, int maxage, int speed)
    super('H',10,0);
    please help

    It's not a problem, it's how Java works. First, if you do not create a constructor in your code, the compiler will generate a default constructor that does not take any arguments. If you do create one or more constructors, the only way to construct an object instance of the class is to use one of the constructors.
    Second, when you extend a class, your are saying the subclass "is a" implementation of the super class. In your case, you are saying Move is an Animal, and Seahorse is a Move (and an Animal as well). This does not seem like a good logical design, but that's a different problem.
    Since you specified that an Animal can only be constructed by passing a char, int, and int, that means that a Move can only be constructed by calling the super class constructor and passing a char, int, and int. Since Move can only be constructed using a char, int and int, Seahorse can only be constructed by calling super(char, int, int);.
    It is possible for a subclass to have a constructor that does not take the same parameters as the super class, but the subclass must call the super class constructor with the correct arguments. For example, you could have.
    public Seahorse() {
       super('S',2,5);
    }The other problem is, Move does not sound like a class. It sounds like a method. Perhaps you might have MobileAnimal, but that would only make sense if there was a corresponding StationaryAnimal. Your classes should model your problem. It's hard to image a problem in which a Seahorse is a Move, and a Move is an Animal. It makes more sense for Animals to be able to move(), which allows a Seahorse to move differently compared to an Octopus.

  • Can defualt inherited the Super Class constructor to sub class ?

    Hi,
    is it passible to inherit the super class constructor by defualt when extends the super class.
    Thanks
    MerlinRoshina

    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • 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

  • Static Inheritance, Constructors --- Classes as objects

    First I asked myself why constructors are not inherited.
    Then I asked myself why Static Methods are not inherited.
    And it all seems to come down to, why Classes are not objects in Java as they are in Smalltalk?
    Is there any reason I'm missing?
    I would love at least inheritable static methods.

    That's OK, but that method would not be inherited, and would execute in the context of the superclass.
    Picture this (a simple "template method"):
    class SuperClass {
         public static void staticMethod() {          
              System.out.println("Static in SuperClass");
              other();          
         public static void other() {          
              System.out.println("other in SuperClass");
    class SubClass extends SuperClass{
         public static void other () {
              System.out.println("other in SubClass");
    Here, I just want to redefine other() in SubClass, but it calls the SuperClass version.
    Let's test:
    public class Test {
         public static void main(String[] args) throws DatabaseErrorException, TableUpdateException {
              SuperClass.staticMethod();
              SubClass.staticMethod();
    Output:
    Static in SuperClass
    other in SuperClass
    Static in SuperClass
    other in SuperClass
    First line calls static in SuperClass, which calls other (found in SuperClass and executed), the output from other is second line.
    Then, the third line shows calling staticMehod in SubClass, which doesn't redefine it, and executes the SuperClass version, that's ok, but when staticMethod calls other, it doesn't look for it in SubClass, but it directly executes the one in SuperClass (which is shown in line 4).

  • Inheritance, constructor and error handling

    I always got problems while trying to call the constructor of a class inheriting from an other.
    I have a concrete problem that is, I think, easy to solve, but I dont find the answer.
    Here is my method that throws an exception:
    public void aMethod() throws MyException
         doSomething();
         if ( errorOccured )
              throw new MyException( "An error occured");
    ...And here is the code of MyException (and here is the error I think):
    public class MyException extends java.lang.Exception
    }When javacing the class containing the first bloc of code I get something like:
    TheClass.java:103: cannot resolve symbol
    symbol  : constructor MyException  (java.lang.String)
    location: class MyException
                            throw new MyException( "An error occured" );
                                  ^If you know how to do that without error. Please give me codes, I will use them as example.
    Thx

    You are correct about where the error is. Although Exception has a constructor "new Exception(String)", if you create a subclass of Exception then you must define this constructor if you want to use it. Not difficult to do:
    public class MyException extends java.lang.Exception{
      public MyException(String s) {
        super(s);

  • Question about constructors and inheritance

    Hello:
    I have these classes:
    public class TIntP4
        protected int val=0;
        public TIntP4(){val=0;}
        public TIntP4(int var)throws Exception
            if(var<0){throw new Exception("TIntP4: value must be positive: "+var);}
            val=var;
        public TIntP4(String var)throws Exception
            this(Integer.parseInt(var));
        public String toString()
            return val+"";
    public class TVF extends TIntP4
    }Using those clases, if I try to compile this:
    TVF  inst=new TVF("12");I get a compiler error: TVF(String) constructor can not be found. I wonder why constructor is not inherited, or if there is a way to avoid this problem without having to add the constructor to the subclass:
    public class TVF extends TIntP4
         public TVF (String var)throws Exception
              super(var);
    }Thanks!!

    I guess that it would not help adding the default constructor:
    public class TVF extends TIntP4
         public TVF ()
               super();
         public TVF (String var)throws Exception
              super(var);
    }The point is that if I had in my super class 4 constructors, should I implement them all in the subclass although I just call the super class constructors?
    Thanks again!

  • Overloading constructor of a child that inherits from a class that inherits from Windows.Forms

    The title might be a bit confusing so here is the layout.
    - classHForm inherits System.Windows.Forms.Form
    - frmDoStuff inherits classHForm  (written by someone else and used in several applications)
      - does not have a constructor specifically defined, so I added the following thinking it would override the parent
    Sub Public New()
    End Sub
    Sub Public New(byval data as string)
    'do stuff
    End Sub
    In my code, I want to instantiate frmDoStuff, but I need to overload it's constructor and populate fields within this form. The problem I'm running into is that when I run this, it is using the constructor from classHForm and ignores any constructor in frmDoStuff.
    I guess you can't override the parent constructor? Is that why it won't work?
    I didn't want to overload the classHForm constructor, but I will if that's the way to go.
    my code:
    dim frm as new frmDoStuff(myString)
    Note: I would love to show actual code, but not allowed. Against company rules.

    Your code is similar. The value I pass into frmDoStuff is supposed to set a value for a textfield.
    Public Class frmDoStuff
    Inherits classHForm
    Public Sub New(ByVal s As String, ByVal gridData() as String)
    txtMyTextField.text = s LoadGrid(gridData)
    End Sub
    I also have a datagridview I need to populate in frmDoStuff and thought I would have another string or string array as a second parameter to the constructor and then call a routine from the constructor to populate the datagrid.
    of course, when I run it this way, the code is not being reached. I'll build an example as COR suggested and maybe someone will see where I'm going wrong.
    [UPDATE]
    I created a simple example and it worked. So, now I need to try to understand what is different in the actual code.
    Here is my example:
    Parent Class inherits form
    Imports System.Windows.Forms
    Public Class classMyForm
    Inherits System.Windows.Forms.Form
    Sub New()
    ' This call is required by the designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    End Sub
    End Class
    Public Class frmDoStuff
    Inherits classMyForm
    Public Sub New()
    ' This call is required by the designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    End Sub
    Public Sub New(ByVal sStuff As String)
    MyBase.New()
    InitializeComponent()
    'Populate the textbox
    TextBox1.Text = sStuff
    End Sub
    End Class
    Public Class frmMyForm
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim frm As New frmDoStuff(TextBox1.Text)
    frm.Show()
    End Sub
    End Class
    Just to recap. The actual parent was created a few years ago and the child form that I'm calling, "frmDoStuff" was created a couple years back and is used in several applications. I need to use it in my application, but I need to populate a couple
    controls when the form is loaded. As you can see in this example, I successfully overloaded the constructor to populate the textbox in frmDoStuff.
    In my real life situation, my overloaded constructor seems to be getting ignored when i step through the code. I'll go back and do some more testing.

Maybe you are looking for