Base class

Hi ,
What will happen if I have a derived class default constructor which does not call the base class constructor as below?
Will this cause any issues?
Thanks,
public class Base{
private String st = null;
public Base (){}
public Base(String str){
st = str;
public class Derived extends Base{
public Derived(){}
}

What will happen if I have a derived class
default constructor which does not call the
base class constructor as below?Another hint: who says the derived class constructor does not call a base class constructor? One very good way to learn about what is happening is to output messages in your constructors. Add the following line to your base class default constructor:
System.out.println("Base default constructor");
Then create an object of your derived class and see what happens.
Will this cause any issues? Why even bother thinking about it? If you always call a base class constructor from your derived class constructors, then you don't have to worry.

Similar Messages

  • AS3: How to create one base class for classes loaded in multiple swfs?

    Our application have 3 different modules and all use
    fscommand and ExternalInterface alot. Now the problem is we are
    combining all those modules, but they all will reside in different
    swfs. Is there any way that they extend to same base class and its
    static members have only one instance accessible by all
    three?

    Hi,
    You can achieve this via Workshop 9.2 by using the exported Ant script for your project as follows:
    -Ensure that all Jars needed to resolve com.bea.p13n.property.EntityPropertyManager (this particular class is found in weblogic92/common/p13n/lib/p13n_ejb.jar) and all referenced classes are added to the Java build path for your WebLogic EJB project (Properties->Java Build Path->Libraries)
    -Export the "Workshop Ant Script" for your WebLogic EJB project (File->Export->Workshop Ant Script); this will generate a "build.xml" Ant script under your project root directory.
    -Edit this default build script as follows: in the call to the "ejbgen" task within the "build" target, add the attribute: propertyFile="ejbgen.properties"
    -Create a file "ejbgen.properties" under the root of your WebLogic EJB project and add the following entry:
    YourSessionBeanClassName.remote.baseClass=com.bea.p13n.property.EntityPropertyManager
    -Add a "<path refid="java.classpath"/>" within the "<classpath>" for the "java" task element that calls "weblogic.ejbc" (this will ensure that the p13n classes are resolved by EJBC)
    Follow the instructions for executing the Ant build script found here: http://edocs.bea.com/workshop/docs92/ws_platform/ideuserguide/conUseCustomAntBuild.html
    For more information on the EJBGen property file support, see: http://e-docs.bea.com/wls/docs92/ejb/EJBGen_reference.html

  • Warning :: Derived class hides the base class virtual function

    We are porting from CC5.3 to CC5.8 compiler with Sun Studio one compiler. After plenty of hurdles we are in the final stage of removing the warning messages... Amoung the plenty the following one is very common and in different files. Why am I getting this error in 5.8 and not in 5.3 compiler....
    Warning: derived_Object::markRead Hides the virtual function base_Object::markRead(ut_SourceCodeLocation&) const in a virtual base
    From this it is easily understandable that the base class mark read was hidden by derived class markRead... when we drive and override the derived class function.... It is all over the place....
    Thank you,
    Saravanan Kannan
    //public: using xx_Object :: markRead;
    virtual void markRead() const;

    The Sun C++ FAQ discusses the warning message:
    http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/c++_faq.html#Coding1
    Notice that warnings are not necessarily errors. But I applaud your desire to fix the code so that it generates no warnings. I wish more of our customers could be persuaded to do the same. :-)
    C++ 5.3 issues this warning, by the way. Example:
    struct B { virtual int foo(int); };
    struct D : B { virtual int foo(double); }; // line 2
    D d;
    line 2: Warning: D::foo hides the virtual function B::foo(int).
    If for your particular code you do not see a warning with C++ 5.3, it would be due to a bug in C++ 5.3 that was later fixed.

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • How to specify a base class for Remote Interface in Workshop 9.2? -- URGENT

    Hi,
    I am trying to create a UUP EJB in WebLogic 9.2 workshop. I am using @FileGeneration to create my home & remote interfaces. And the generated remote interface is extending javax.ejb.EJBObject;I want my remote interface to extend com.bea.p13n.property.EntityPropertyManager which in turn implements javax.ejb.EJBObject. Can someone tell how i can do it in Workshop?.
    I came across Predefined Variable: remote.baseClass and as per docume
    ntation..."If specified, the value of this variable will be used as the base class for all generated remote classes. Where i should specify it?. @FileGeneration does nt have any option for it. Any help is grtly appreciated.
    Following are my code snippets:
    IMPL Class
    @FileGeneration(remoteClass = Constants.Bool.TRUE,remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE,remoteClassName = "MyEntityPropertyManager",remoteHomeName = "MyEntityPropertyManagerHome")
    public class MyEntityPropertyManagerImpl extends GenericSessionBean implements
              SessionBean {
    //code
    }

    This question was posted to both the bea.workshop.developer.general and weblogic.developer.interest.workshop (I had replied to the later on 10/19); after seeing an identical question today on this list want to include a reference to that reply here:
    http://forums.bea.com/bea/message.jspa?messageID=600044925&tstart=0
    -Rob

  • How to expose and code the event handlers of a base class?

    I have created a class that inherits NumericUpDown. When I instantiate an object from that class, I can make it visible and have it appear on my form just like any other NUD. How can I get that instantiated object to expose the event handlers of its base
    class, the NUD in this case, so that, for example, I can tell the client what action to take when the value of the instantiated object changes?
    Thanks for your help.

    I am not sure exactly what you mean.  Are you adding your NUD controls to the Form at design time from the toolbox or adding them in code at run time?  If you are adding them to the form from the toolbox then you access the events the same way
    you would a standart NUD control.   If it is at runtime and you have a fixed amount of them you are going to add then you can declare them Class Scoped using the
    WithEvents keyword which will let you access all their events.
    Public Class Form1
    Private WithEvents Nud1 As New NUD
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.Controls.Add(Nud1)
    End Sub
    Private Sub Nud1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Nud1.ValueChanged
    Me.Text = Nud1.Value.ToString
    End Sub
    End Class
    Public Class NUD
    Inherits NumericUpDown
    'Your custom code to make it work how you want...
    End Class
     If this is not what you are doing then you may need to explain a bit more and show the code you are using so we understand better.
    If you say it can`t be done then i`ll try it

  • Error with instance variable and constructor of base class

    I am getting the error on the following statement "protected Point apoint" of by base class. What is causing this problem? See my code:
    package Shapes;
    public abstract class Shapes
         protected Point apoint; / ****error at this line****/
         public void move(double xdelta, double ydelta)
              apoint.x += xdelta;
              apoint.y += ydelta;
    public abstract void distance();
    public abstract void show();
    public String toString()
    return "\nThe starting point is at coordinates ("+x+","+y+")";
    package Shapes;
    public class Lines extends Shapes
    protected Point start;
    protected Point end;
         protected double x;
         protected double y;
         double delta;
         public Lines( final Point apoint, final Point bpoint)
    start.x = apoint.x;
              start.y = apoint.y;
              end.x = bpoint.x;
              end.y = bpoint.y;
    public Lines(double xstart, double ystart, double xend, double yend)
    this.xstart = xstart;
              this.ystart = ystart;
              this.xend = xend;
              this.yend = yend;
         public Lines(double x, double y)
              this.x = x;
              this.y = y;
                   public void distance(final Lines start, final Lines end)
                        delta = abs(Math.sqrt (super.x - start.x) * (super.x - end.x) +
                        (super.y - start.y) * (super.y - end.y));
                   Lines move(Point start, double delta)
                        end.x += delta;
                        end.y += delta;
                        return new Point(end);
    public Lines show()
    g.drawLine( start.x, start.y, end.x, end.y);
    public String toString()
    return super.toString()+ "\n moved distance is("
                   + start + ") : (" + end + ")"
                   +" \n to position(" + start + " ) : (" + end + ")";
    package Shapes;
    public class Rectangle extends Lines
         double delta;
    public Rectangle (Point top_lft_pt, Point bottom_rght_pt)
    super(top_lft_pt, bottom_rght_pt);
    public Rectangle(double x_top_lft, double y_top_lft, double x_bottom_rght, double y_bottom_rght)
    super(x_top_lft, y_top_lft, x_bottom_rght, y_bottom_rght);
         public Rectantgle is_it_diagonal()
              if(top_lft.x > bottom_rght.x && bottom_rght.x < top_lft.x)
                   System.out.println("Point are Not Diagonal");
                   public void distance(double delta)
                        delta = abs(Math.sqrt (top_lft.x - bottom_rght.x) * (top_lft.x - botton_rght.x) +
                        (top_lft.y - bottom_rght.y) * (top_lft.y - bottom_rght.y));
                   public Rectangle move(final Point top_lft_pt, double delta)
                        bottom_rght.x += delta;
                        bottom_rght.y += delta;
                        return new Point(bottom_rght_pt);
                   public void get_top_rght_coords()
                        Point top_rght = new Point();
                        top_rght.x = bottom_rght.x;
                        top_rght.y = top_lft.y;
                   public void get_bottom_left_coords()
                        Point bottom_lft = new Point();
                        bottom_lft.x = top_lft.x;
                        bottom_lft.y = bottom_rght.y;
         public Rectangle show()
                        g.drawLine(top_lft.x, top_lft.y, top_rght_x, top_rght_y);
                        g.drawLine(bottom_lft.x, bottom_lft.y, bottom_rght.x, bottom_rght.y);
                        g.drawLine(top_lft.x, top_lft.y, bottom_lft.x, bottom_lft.y);
                        g.drawLine(top_rght.x, top_rght.y, bottom_rght.x, bottom_rght.y);
    package Shapes;
    public class Circles extends Lines
    protected double radius;
         public double delta;
         protected Point center;
    public Circles(double x, double y, double radians)
    super(x, y);
              radius = radians;
         public Circles(Point acenter)
              center.x = acenter.x;
              center.y = acenter.y;
    public void distance()
    delta = abs(Math.sqrt(super.x - x) * (super.x - x) + (super.y - y) * (super.y -y));
         public Circles move(final Point Circles, double delta)
              return new Point(Circles);
    public void show()
    g.drawOval(Circles.x, Circles.y, radius, radius);
    package Shapes;
    import java .math .*;
    import java.util .Random ;
    public class ShapesDriver
    Shapes[] aShape = new Shapes[10];
    static double range = 101.0;
    static Random r1 = new Random();
    public static void main(String [] args)
    double[][] coords = new double[10][10];
    double[] radians = new double [10];
    Shapes anyShape = {
    new Circles(radians),
    new Lines(coords),
    new Rectangle(coords)
    Shapes aShape; /***error at this line***/
              for(int i = 1; i <= coords.length; i++)
    for(int j = 1; j <= coords.length; j++)
                                                      coords[i][j] = r1.nextDouble () * range;
                                                      radians[j] = r1.nextDouble () * range;
    aShape[i] = anyShape[r1.nextInt(aShape.length)];
    System.exit(1);

    Thanks for your help with this problem. Now I have another problem that I am having a hard time figuring out. My program is using inheritance and polymorphism. I trying to use only one version of methods in the superclass points which extends the shapes class which is the abstract superclass vs. repeating the implementation of the methods (move, show, etc.) in each of the subclasses. The error I am getting is this "declare the class abstract, or implement abstract member 'Point Shapes.move()'. As you see, move is declared abstract and of type point in the Shapes superclass and it's behavior is implemented in the subclass Points extending Shapes. The other subclasses, circle, rectangle and lines will invoke the move method from Points and return a new point object. Why I am I getting the error to declare or implement move when the implementation is in Point?
    Below is code, please help?
    import java .awt .Point ;
    public class ShapesDriver
         public static void main(String args[])
              int count = 0;
              int choice;
              Point start = null;
              Point end = null;
              System.out .println(" 1 i am here");
              start = new Point((int)(Math.random()* 10.0), (int)(Math.random()* 10.0));
              end = new Point((int)(Math.random()* 10.0), (int)(Math.random()* 10.0));
         System.out .println(" 2 i am here");     
         System.out.println (start);
         System.out.println(end);                         
         for(int i = 0; i <= count; i++)
              System.out .println(" 3 i am here");
              choice = (int)(4.0 * Math.random());
              System.out .println(" 4 i am here");
              System.out.println (choice);     
         switch(choice)
              case 0: //Lines
              System.out .println(" 5 i am here");
              Lines apoint = new Lines((int)(Math.random()* 10.0), (int)(Math.random()* 10.0),
                                  (int)(Math.random()* 10.0), (int)(Math.random()* 10.0));
              Point coords = new Point((int)(Math.random()* 10.0),
                             (int)(Math.random()* 10.0));
              new Point((int)(Math.random()* 10.0),
                             (int)(Math.random()* 10.0));
              break;
              case 1: //Circles
              System.out .println(" 6 i am here");
              Circles center = new Circles((double)(Math.random()* 10.0),
              (double)(Math.random()* 10.0), (double)(Math.random()* 10.0),
              (double)(Math.random()* 10.0),(double)(Math.random()* 10.0));
              Circles centerpt = new Circles((int)(Math.random()* 10.0),
              (int)(Math.random()* 10.0), (int)(Math.random()* 10.0),
              (int)(Math.random()* 10.0), (double)(Math.random()* 10.0));
         break;
              case 2: //Rectangles
         System.out .println(" 7 i am here");
              Rectangle top_lft_pt = new Rectangle ((double)(Math.random()* 10.0),
                             (double)(Math.random()* 10.0), (double)(Math.random()* 10.0),
                             (double)(Math.random()* 10.0), (double)(Math.random()* 10.0),
                             (double)(Math.random()* 10.0));
              Rectangle bottom_rgt_pt = new Rectangle ((double)(Math.random()* 10.0),
                   (double)(Math.random()* 10.0), (int)(Math.random()* 10.0),
                             (int)(Math.random()* 10.0), (int)(Math.random()* 10.0),
                             (int)(Math.random()* 10.0));
         break;
         default:
         System.out .println(" 9 i am here");
         System.out.println("\nInvalid shape choice =" + choice);
         System.exit(0);
         break;
         try
                   System.in.read();
                   catch(java.io.IOException ioe)
    import java .awt .Point ;
    public abstract class Shapes
         private String shape;
         public Shapes(String ashape)
              shape = new String(ashape);
         public abstract Point move();
         public double distance()
              return 0.0;
         public abstract void show();
         public String toString()
              return "\nThis shape is a" + shape;
    import java .awt .Point ;
    public class Rectangle extends Points
         protected Point top_lft;
         protected Point top_rgt;
         protected Point bottom_lft;
         protected double top_lft_x;
         protected double top_lft_y;
         protected double bottom_rgt_x;
         protected double bottom_rgt_y;
         protected Point bottom_rgt;
         protected double delta = 0;
         protected String shape = "Rectangle";
         public Rectangle(double x, double y, double top_lft_x,
                             double top_lft_y, double bottom_rgt_x,
                             double bottom_rgt_y)
              super(x, y);
              top_lft_x = top_lft_x;
              top_lft_y = top_lft_y;
              bottom_rgt_x = bottom_rgt_x;
              bottom_rgt_y = bottom_rgt_y;
         public Rectangle( double x, double y, Point bottom_rgt, Point top_lft)
              super(x, y);
              bottom_rgt_x = bottom_rgt.x;
              bottom_rgt_y = bottom_rgt.y;
              top_lft_x = top_lft.x;
              top_lft_y = top_lft.y;
         public String toString()
              return super.toString() + " coordinates top left= " + top_lft_x + "," + top_lft_y + "and bottom right" +
                   bottom_rgt_x + "," + bottom_rgt_y + ")";
         public void is_it_diagonal()
              if(top_lft_x < bottom_rgt_x && bottom_rgt_x > top_lft_x)
                   System.out.println("Points are Not Diagonal");
              public double distance()
                   distance ();
                   return delta;
              public Point move(Point top_lft)
                   move();
                   bottom_rgt_x += delta;
                   bottom_rgt_y += delta;
                   return top_lft;
              public void get_other_coords()
                   top_rgt.x = bottom_rgt.x;
              top_rgt.y = top_lft.y;
                   bottom_lft.x = top_lft.x;
                   bottom_lft.y = bottom_rgt.y;
              public void show()
                   super.show();
                   System.out.println("new coords are :");
                   System.out .println ("(" + top_lft_x + "," + top_lft_y + ")");
                   System.out .println ("top right(" + top_rgt + ")");
                   System.out .println ("(" + bottom_rgt_x + "," + bottom_rgt_y + ")");
                   System.out .println ("bottom right(" + bottom_rgt + ")");
    import java .awt .Point ;
    public class Points extends Shapes
         protected double delta = 0.0;
         protected double x;
         protected double y;
         protected String ashape = "Points";
         public Points( double x, double y)
              super("Points");
              x = x;
              y = y;
         public Points( Point start)
              super("Points");
              x = start.x;
              y = start.y;          
         public String toString()
              return super.toString() + "References coordinates(" + x + y + ")";
         public double distance(double x1, double y1 )
              return delta =(Math.sqrt(x - x1) * (x - x1) + (y - y1) *
              (y - y1));
         public Point move(Point pts)
              pts.x += delta;
              pts.y += delta;
              return pts;
         public void show()
              System.out.println("This shape is a" + ashape + "(" +
                                  "(" + x+ "," + y + ")");
    import java .awt .Point ;
    public class Lines extends Points
         double delta = 0;
         protected double x;
         protected double y;
         protected String ashape = "Lines";
         public Lines( double x1, double y1, double x, double y)
              super(x1,y1);
              x = x;
              y = y;
         public Lines(Point start, Point end)
              super(start);
              x = end.x;
              y = end.y;
         public String toString(Point end)
              return super.toString() + "line points = (" + x + "," + y +
                   "(" + end + ")";
         public double distance()
              distance ();
              return delta;
         public Point move(Point lines)
              move ();
              return lines;
         public void show()
              System.out.println("This shape is a" + ashape + "(" +
                                  "(" + x + "," + y + ")");
    import java .awt .Point ;
    public class Circles extends Points
    protected double radius;
    protected double xcenter;
    protected double ycenter;
    protected String ashape = "Circle";
         public Circles( double x, double y, double cx, double cy, double radians)
              super(x, y);
              xcenter = cx;
              ycenter = cy;
              radius = radians;
         public Circles( Point acenter, Point ref, double radians)
              super(ref);
              xcenter = acenter.x;
              ycenter = acenter.y;
              radius = radians;
         public String toString(Point ref)
              return super.toString() + " reference points (" +
                   ref + ")" +
                   "center coordinates (" + xcenter + "," + ycenter + ")";
              public double distance(Point ref)
                   return (Math.sqrt(ref.x - xcenter) * (ref.x - xcenter)
                             + (ref.y - ycenter) *
              (ref.y - ycenter));
              public Point move(Point center)
                   move();
                   return center;
              public void show()
                   System.out.println("This shape is a" + ashape + "(" +
                                  "(" + xcenter + "," + ycenter + ")");

  • How to call derived class to base class

    Hello everybody,
    I create a GUi application in java swing. Now i want to navigate between the screen but the timing between the screen is very slow bcoz i imported the class from package to another package. Now i want to extends one package to another package to reduce the navigation time but it saying error bcoz i cant able to call my derived class to base class. if anyone know the answer for this please answer this immediately.
    If any other method is there to optimise the navigation time please tell me
    by
    (kamal)

    Sorry, I've got major difficulties understanding your query:
    I create a GUi application in java
    ication in java swing. ok
    Now i want to navigate between
    the screenwhat? switch screens? display a different dialog?
    but the timing between the screen is very
    slowtiming? do you mean the time it takes to display a different dialog?
    bcoz i imported the class from package to
    another package.how did you come to the conclusion that that is the reason for the slowness? Did you do any profiling or is this just guess-work?

  • Set fields of derived class in base class constructor via reflection?

    Does the Java Language Specification explicitly allow setting of fields of a derived class from within the base class' constructor via reflection? The following test case runs green, but I would really like to know if this Java code is compatible among different VM implementations.
    Many thanks for your feedback!
    Norman
    public class DerivedClassReflectionWorksInBaseClassConstructorTest extends TestCase {
    abstract static class A {
        A() {
            try {
                getClass().getDeclaredField("x").setInt(this, 42);
            } catch (Exception e) {
                throw new RuntimeException(e);
    static class B extends A {
        int x;
        B() {
        B(int x) {
            this.x = x;
    public void testThatItWorks() {
        assertEquals(42, new B().x);
        assertEquals(99, new B(99).x);
    }

    why not just put a method in the superclass that the subclasses can call to initialize the subclass member variable?In derived classes (which are plug-ins), clients can use a field annotation which provides some parameter metadata such as validators and the default value. The framework must set the default value of fields, before the class' initializer or constructors are called. If the framework would do this after derived class' initializer or constructors are called, they would be overwritten:
    Framework:
    public abstract class Operator {
        public abstract void initialize();
    }Plug-In:
    public class SomeOperator extends Operator {
        @Parameter(defaultValue="42", interval="[0,100)")
        double threshold;
        @Parameter(defaultValue="C", valueSet="A,B,C")
        String mode;
        public void setThreshold(double threshold) {this.threshold = threshold;}
        public void setMode(String mode) {this.mode = mode;}
        // called by the framework after default values have been set
        public void initialize() {
    }On the other hand, the default values and other metadata are also used to create GUIs and XML I/O for the derived operator class, without having it instantiated. So we cannot use the initial instance field values for that, because we don't have an instance.

  • Reflection: attributes from the base class

    Is there a way to get the attributes from the base class of a derived class via reflection? I only found methods to get the attributes from the derived class.
    Example:
    class A
    int a = 4;
    class B extends A
    int b = 5;
    Object unknown = new B();
    Code/Idea to get all attributes from baseclass A using unknown (here: a=4)?

    Thank you all for your hints. The mistake I make, was to use the baseclass, and not the derived class for getting the attributes. By using an extra parameter of type class I got all attributes in their context.
       private StringBuffer getDump(Object obj, Class cl)
             dmp.append(cl.getName() + " {\n");
             Field[] attribute = cl.getDeclaredFields();             <--- only the fields of the current class
             for (int j = 0; j < attribute.length; j++)
                attribute[j].setAccessible(true);
                try
                   if (attribute[j].getType().isPrimitive() || attribute[j].getType() == String.class)
                      dmp.append(attribute[j].getName() + "=" + attribute[j].get(obj) + "\n");
                   else
                      if (((attribute[j].getModifiers() & Modifier.STATIC) != Modifier.STATIC) &&
                          (attribute[j].getType().getName().startsWith("java.lang") == false) &&
                          ((attribute[j].getModifiers() & Modifier.FINAL) != Modifier.FINAL))
                         dmp.append(getDump(attribute[j].get(obj), attribute[j].get(obj).getClass())); <- recursive call
                catch (IllegalAccessException ex)
                   ex.printStackTrace();
             dmp.append("}");
          return dmp;
       }

  • Base class vs derived class

    We have entity classes that we use to access our database. We have subclasses derived from these entity classes that apply business rules. For instance, the base class AddressEntity has a
    setAddress2(string) that AddressEntity.select() uses to set a class variable with data retrieved from the database. The derived class Address also has a setAddress2(string) method that puts restrictions on the length of the data. I want the AddressEntity.select() method to use the base class method AddressEntity.setAddress2(). I've tried using this.setAddress2() in AddressEntity.select() but the derived class method is still used. Any suggestions?
    Thanks,
    Joe

    If you need to call some methods on the base class sometimes and some methods on the derived class other times, but using the same object, then yes dubwai is right you should revisit your Object hierarchy.
    One simple way to do what you are asking is to have your method(s) look like this:
    void setAddress2(String sAddress) { setAddress2(sAddress, true); }
    void setAddress2(String sAddress, boolean bRestrictLength) {
      // real method
    }then you could just look at the variable bRestrictLength to see if you need to restrict the length, and have it default to true. In this way you can use overloading to solve your problem.

  • How to call a method of a base class if the base class is abstract...

    This is my sample code>>>>
    abstract class b {
         public void display() {
              System.out.println("I am in Base Class");
    class test extends b {
         public static void main(String[] args) {
              test obj = new test();
              obj.display();
         public void display() {
              System.out.println("I am in Derived Class");
    I want to call base class version of display with derived class object.........is it possible....

    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    * headdesk *
    Enough with the friggin' zombie threads already!

  • Base Class NI View Fails

    Hi
    I am currently trying to leverage of my existing codebase by creating a Base class View containing common functionality. My goal is to create the Base class in the form of a (MFC) CFormView with an associated dialog resource containing all my NI controls and underlying code. From there I intend to derive further View Classes based on the former. I have tried this and cannot seem to get the Base class to recognise its members,i.e the Ni controls, whilst the view displays fine and I can see all the Ni controls on form derived from the Base class I cannot execute any of the base class meber functions that need a reference to the Ni controls. If you could give me an example of a project that derives it view from a Base class with ActiveX contro
    ls in it I would be very appreciative.....
    Regards

    I was going to investigate it a little before posting, but
    I'm not sure I can go any further on my own.
    I am using the Yahoo Astra Flash Components. When I add a
    Tree component, and give it a dataProvider that does not use any
    nested nodes, it gives me the error. If I use even 1 nested node,
    then it works correctly.
    I am assuming that the error is stemming from the Yahoo
    Component somewhere, just need to run down what is causing it.

  • The definition of base class Application was not found.

    Hello:
    I have been coding in Flash Builder Burrito and publishing to my Xoom for a few weeks. All of a sudden at the end of the day I'm getting this compiler error which says:
    1017: The definition of base class Application was not found.    AppName.mxml    /AppName/src    Unknown    Flex Problem
    I sometimes hit the wrong key with I try to copy and paste and all of a sudden a new window will open for source of a default component which I never wanted to edit. I'm afraid I somehow deleted or modified the default class defnition of Application?
    I don't understand why this would come out of the blue, I was working on a function within a class that was drawing points  ... Then all off a sudden I'm getting this error and it's driving me nuts.
    I tried to reinstall FB Burrito on my Mac, but after all that work it still says the same thing. Wouldn't it replace the default class defs?
    Please help!

    Wow, some really strange behavior.
    OK, so here is what I'm going through. I reinstall, import the project and compiles.
    Then I uncomment the new section which contains the following code:
    lineStyle(1.0,0x8ea4bf);
    var line_commands:Vector.<int> = new Vector.<int>();
    line_commands.push(GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO);
    var line_coord:Vector.<Number> = new Vector.<Number>();
    line_coord.push(0,0, newW, angle, newW, (newH+angle), 0, newH);
    drawPath(line_commands, line_coord);
    I get 3 diffrent errors, which lead up to the error listed in the topic.
    At first it says that "int" isn't a valid type and it points to this line:
    var line_commands:Vector.<int> = new Vector.<int>();
    Then I take int out so the line looks like this:
    var line_commands:Vector = new Vector();
    Then it says I can't nest classes and it points to the main MXML. I go to the main MXML then the error switches to say "The definition of base class Application was not found.".
    I did figure out how to fix this with out reinstalling. I have to delete the project from my list (making sure to comment out the code above), then re-launch FB Burrito, then re-import the project and it works.
    This is way nuts! I dont understand ... am I crazy?

  • Flex/AS3 Best way to construct a derived class instance from an existing base class instance?

    What is the best way to handle the instantiation of a derived class from an existing base class.
    I have a base class which is being created via remote_object [RemoteClass alias] from the server.   I have other specialized classes that are derived from this baseclass, but serialization with the server always happens with the base class.     The base class has meta data that defines what the derived class is, for example
    [RemoteClass (alias="com.myco...')]
    public Class Base
         public var derivedType:String;
         public function Base()
    public Class Derived extends Base
         public "some other data"
         public function Derived()
    In my Cairgorm command which retrieves this object from ther server I want to do this:
    public function result (event: Object):void
        var baseInstance:Base = event.result;
         if (baseInstance.derivedType = "derived")
              var derivedInstance:Derived = new Derived( baseInstance );
    What is the most efficient way of doing this?   It appears to me that doing a deep-copy/clone and instantiation of the derived class is pretty inefficient as far as memory allocation and data movement via the copy.

    Thanks for the assistance.  Let me try to clarify.
    MY UI requires a number of composite classes.    The individual components of the composite classes are being transfered to/from the server at different times depending upone which component has changed state.    The construction of the composite classes from the base class happens in my clients business logic.
    Composition happens in a derived class; but server syncronization happens using the base class.    When I recieve the object from Blazeds through the remote object event, it is in the form of the base class.  I then need to instantiate the derived class and copy the elements of the base class into it (for later composite construction).   And likewise when sending the base class back to the server, I need to upcast the derived class to its base class.   But in this case just a mere upcast does not work.  I actually need to create a new base class and copy the attrbutes into it.  I believe this is limitation of how remoting works on Flex/AS3.
    My question is, what is the best way to turn my base class into it's derived class so further composite construction can take place.   The way I am currently doing it is to create a  load method on the base class, that takes the base class as on argument.  The load function, copies all of the instance attribute references from the base class to the target class.
    public Class Base
         public function Base()
         public function load(fromClass:Base)
        {  //  copy the references for all of the instance attributes from the fromClass to this class }
    Then,  after I recieve the base class from the server.   I create a new derived class and pass the base class into the load function like this:
                for (var i:int=0; i < event.result.length; i++) {
                    var derived:Derived = new Derived();
                    derived.load(event.result[i]);
    The drawbacks of this approach is that it now requires 2 extra instance creations per object serialization.   One on recieving the object from the server and one sending it to the server.    I assume copying references are pretty efficient.  But, there is probably some GC issues.     The worst of it is in code maintenance.   The load function now has to be manually maintained and kept in sync with the server class.
    It would be interesting to hear how others have solved this problem.      The server side is an existing application with around 2M LOC, so changing the code on the server is a non-starter.
    Thanks for your help.

Maybe you are looking for

  • Using multiple sql query

    Im writing a jsp that pulls data from the database and loads it into dropdown-list looks like this: <select name="Source"> <% conn = DriverManager.getConnection(url, username, password); Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SEN

  • No maps in Calendar events

    I've looked at events carried over from before the Mavericks upgrade and no events show maps where a valid address exists. I've tried creating new events with addresses and same problem. I can't find a place to turn this feature on. Any suggestions?

  • I want to configure my ipad2 only to use cellular even for large Apps download

    since cellular network cheaper in india, want to configure ipad2 to download all Apps even larger size through cellular network. need a help.

  • How to get cluster name with c++ API?

    Hi everyone, I want to get cluster name with c++ API, do you know how to do that? Thanks very much!!! Guangyin

  • Placing InDesign files into inDesign files

    This is more a two-part workflow question to make sure I start off on a good footing. I'm working with another person putting together a 40 page brochure that has 6 different sections formatted the same way, with some photos plus a cover. I'm doing a