Object as Superclass

Hi All,
why do java has Object Class????
Thanks,
Mahesh.

Hi All,
why do java has Object Class????Because that way we can have methods that can operate on any type of object--taking an Object as a parameter, and we can have certain methods--toString, etc.--that we know will always be available on every object.

Similar Messages

  • Problem Create object from superclass

    Hi,
    I have a problem with classes:
    I have one abstract superclass which has a method to create objecto for its children class.
    CREATE OBJECT R_FLIGHT TYPE (l_class_name)
         EXPORTING
           i_sflight = l_sflight.
    l_class_name: has the name of my children class
    My children class has this properties:
    A dump its triggered when I try to create object from the superclass.
    Best Regards

    Hello,
    I think that you defined the instantiation level of the superclass as PROTECTED & from the screenshot i can see that the instantiation level is protected & the class is marked as "Final".
    Are you having a factory method which returns the instance of the abstract class & you use it to achieve polymorphism?
    May be a little bit insight into your coding can help us
    BR,
    Suhas

  • Object related

    hi all...
    I have written extended class. In that super class has 3 methods and subclass has 4 methods. I want to make sub class object(excluding superclass methods) only serializable. How can i do this...
    Regards

    mahesh3018 wrote:
    hi all...
    I have written extended class. In that super class has 3 methods and subclass has 4 methods. I want to make sub class object(excluding superclass methods) only serializable. How can i do this...
    RegardsPolymorphism demands that if the super class has 3 non-private methods, and the subclass has 4 non-private methods, that a client will be able to call all 7 methods when given a reference to an instance of the subclass. Serialization won't affect that.
    I agree with the poster who thought there was confusion about methods and members. "transient" is the key here.
    %

  • Passing superclass as parameter where subclass is required

    if
    class A1 extends A { ...}
    and in some other class
         class B {
              B( A1 a1) { }
    and another class
         class C {
              A a = new A;
              B b = new B(a);
              // I'm sending an object of superclass where that of subclass is required
    Is this possible ,or is there any way where I dont have to make any change in B & C all I can do is modify A1 which extends A ( possibly a lib class).
    Thanks

    not possable.
    A1 has more than A, you could do it the other way round (pass A1 to something that need A).

  • Superclass and subclass

    Ok I have now reached the area of using Superclass and subclass in my
    self study of Java, and I am stumped on what is I am sure is a very
    easy concept. Here's the Scenerio. I have three classes Point, Circle
    and InheritanceTest. Point is the Superclass that is being referenced
    from Circle InheritanceTest has the main Method.
    Inside the Point class the book I am using has this note inside the
    constructor.
    public void Point{
    //implicit call to superclass constructor occurs here
    setPoint(0,0);
    My question is this, Is the call to it's self or the object class?
    And do you Know which one it is referring to?
    Thanks in advance

    public void Point{
    //implicit call to superclass constructor occurs here
    setPoint(0,0);
    }When you extend a class, every constructor of the new class must call a constructor of the extended class- this is done by using super() or super(some arguments). Note that if you don't put this in, java will implicitly call super() for you- it basically inserts this call into your new constructor.
    As for the setPoint() method, if your new class has a method of this name and signature (i.e. same type of arguments), it will call your sub-class's method. If the sub-class does not have a method like this defined, it will look for this method in the super-class and call that one. In this way, you are inheriting the methods of the super-class. Unless you specifically override a method (give a method of the same name in type in the sub-class as in the super-class), all public or protected methods of the super-class can be used as if they were methods of your sub-class.
    Check this out:
    public class SuperClass
         private int value = 0;
         public SuperClass()
              super();
              // Calling the default constructor of Object, the superclass of this class
         public SuperClass(int value)
              // Implicitly calling super() since a superclass constructor was not given explicitly
              this.value = value;
         public int getValue()
              return value;
         public void setValue(int value)
         this.value = value;
         public void changeValue()
              setValue(getValue() + 1);
    public class SubClass
         public SubClass()
              super(0);     // Calls the SuperClass(int) constructor
         public SubClass(int value)
              // Implicit call to SuperClass() constructor
              setValue(value);
         public void changeValue()
              // Overrides the SuperClass method of the same name
              setValue(getValue() - 1);
         public void useSuperChangeValue()
              super.changeValue();     // Calls SuperClass.changeValue()
         // If you want to use the super-class methods, even if they have been overridden,
         // use the keyword "super" to reference the superclass

  • Casting objects question

    class SuperClass {
         public static void staticMethod() {
              System.out.println("static SuperClass method");
         public void instanceMethod() {
              System.out.println("instance SuperClass method");
    class SubClass extends SuperClass {
         public static void staticMethod() {
              System.out.println("static SubClass method");
         public void instanceMethod() {
              System.out.println("instance SubClass method");
    public class TestSuperSub {
         public static void main(String[] args) {
              SuperClass superclass = new SuperClass();
              SubClass subclass= new SubClass();
              superclass.instanceMethod();
              subclass.instanceMethod();
              ((SuperClass)subclass).instanceMethod(); //<--uses the instance method from SubClass
              superclass.staticMethod();
              subclass.staticMethod();
              ((SuperClass)subclass).staticMethod(); //<---uses the static method from SuperClass
    I don't understand why calling the SubClass instance method when SubClass is cast to SuperClass runs the SubClass method but not with the static method. What is actually happening on the last line?
    RON

    RonNYC2 wrote:
    What I'm asking is, why doesn't upcasting retrieve the instance method of the superclass since it retrieves the static method of the superclass? I know that the instance method is overridden and static method cannot be. What I'm asking is, what kind of object is (SuperClass)Subclass? Is it an object which uses only the superclass methods (it doesn't seem so)?Casting it doesn't change the fact that the underlying object is still a Subclass type.
    When invoking a static method however, you're telling the compiler to use the version from the SuperClass. The line of code in question is just as if you had coded:
    SuperClass.staticMethod();which is one reason why you should ALWAYS (or at least almost always, there are probably corner cases - statements with absolutes just ask for someone to shoot it down with an exception example) invoke static methods via the class name itself rather than through an object instance.

  • Narrowing cast and widening cast

    Hi All,
           I want to know what is the use of a narrowing cast and a widening cast in ABAP objects.
    Can someone please give an example ?
    Regards,
    Ashish

    Hi,
    Check out this link, This will guide you on ABAP Objects
    http://www.sap-press.de/katalog/buecher/htmlleseproben/gp/htmlprobID-28?GalileoSession=22448306A3l7UG82GU8#level3~3
    Both narrow and wide casting are related to inheritance.
    In Narrow casting, you assign a runtime object of subclass to runtime object of superclass. By this assignment , you can access your subclass by using runtime object of your superclass. But here the important point is that, you are assigning subclass reference to super class reference, so you can only access the inherited components of subclass through super class reference.
    Suppose you have a super class lcl_vehicle. it has two subclasses lcl_car and lcl_truck.
    r_vehicle = r_car.
    In Wide casting, you assign a superclass reference to subclass reference . Before this, you do narrow casting,
    Now when you assign a superclass reference to subclass reference. You can access the inherited as well as the specific components of subclass.
    taking the same example,
    r_car ?= r_vehicle.
    '?='  wide cast operator.
    Regards
    Abhijeet

  • IfsException: IFS-10407: Invalid Attribute name

    I'm trying to programmaticaly create an instance of the custom class AsapPublisher that I have created. When I attempt to set the attribute jobTitle I get the IFS exception 10407. The attribute jobTitle exists so I unsure why I'm getting this error. Below is my code and stack trace. If anyone can see where I'm going wrong I would appreciate input. Thanks!
    instantiatePublisher.jsp
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    <%@ page import="oracle.ifs.common.IfsException" %>
    <%@ page import="oracle.ifs.beans.LibrarySession" %>
    <%@ page import="oracle.ifs.beans.LibraryService" %>
    <%@ page import="java.util.Locale" %>
    <%@ page import="oracle.ifs.beans.ClassObject" %>
    <%@ page import="java.io.*" %>
    <%@ page import="publishasap.AsapPublisher" %>
    <%@ page import="publishasap.definition.AsapPublisherDef" %>
    <%@ page import="publishasap.definition.AsapPublisherContactDef" %>
    <%@ page import="oracle.ifs.common.CleartextCredential" %>
    <%@ page import="oracle.ifs.common.ConnectOptions" %>
    <%
    String username = "system";
    String password = "manager";
    String serviceName = "IfsDefault";
    String servicePassword = "ifssys";
    try
    LibraryService ifsService = new LibraryService();
    CleartextCredential credentials = new CleartextCredential(username,password);
    ConnectOptions connectOpts = new ConnectOptions();
    connectOpts.setLocale(Locale.getDefault());
    connectOpts.setServiceName(serviceName);
    connectOpts.setServicePassword(servicePassword);
    LibrarySession ifsSession = ifsService.connect(credentials,connectOpts);
    ifsSession.setAdministrationMode(true);
    //set the AsapPublisher attributes and create a publisher instance
    AsapPublisherDef publisher = new AsapPublisherDef(ifsSession);
    publisher.setCompanyName(request.getParameter("pubName"));
    publisher.setAddress1(request.getParameter("address1"));
    publisher.setAddress2(request.getParameter("address2"));
    publisher.setCity(request.getParameter("city"));
    publisher.setState(request.getParameter("state"));
    publisher.setPostalCode(request.getParameter("postalCode"));
    publisher.setCountry(request.getParameter("country"));
    publisher.setPhoneNumber(request.getParameter("phoneNumber"));
    publisher.setPublisherDescription(request.getParameter("pubDescription"));
    out.println("here");
    //create the publisher contact object
    AsapPublisherContactDef contact = new AsapPublisherContactDef(ifsSession);
    contact.setClassObject(ClassObject.getClassObjectFromLabel(ifsSession,publishasap.AsapPublisherContact.CLASS_NAME));
    contact.setJobTitle(request.getParameter("jobTitle"));
    contact.setPrefix(request.getParameter("prefix"));
    contact.setFirstName(request.getParameter("fName"));
    contact.setMInitial(request.getParameter("mInitial"));
    contact.setLastName(request.getParameter("lName"));
    contact.setSuffix(request.getParameter("suffix"));
    contact.setEmail1(request.getParameter("email1"));
    contact.setEmail2(request.getParameter("email2"));
    contact.setFax(request.getParameter("fax"));
    contact.setWkPhone(request.getParameter("workPhone"));
    contact.setUsername(request.getParameter("username"));
    contact.setPassword(request.getParameter("password"));
    publisher.setAsapPublisherContact(contact);
    AsapPublisher createPub = (AsapPublisher) ifsSession.createPublicObject(contact);
    ifsSession.disconnect();
    catch(IfsException e)
    out.println("System was unable to create an author object");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    e.printStackTrace(pw);
    String trace = sw.toString();
    sw.close();
    pw.close();
    out.println(trace);
    IfsException.setVerboseMessage(true);
    String message = e.getMessage();
    out.println(message);
    %>
    AsapPublisher.java
    // Copyright (c) 2000 Thin Data Solutions
    package publish asap;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import oracle.ifs.server.S_LibraryObjectData;
    import publishasap.AsapCustomer;
    import publishasap.AsapPublisherContact;
    import publishasap.definition.AsapPublisherContactDef;
    * A Bean class.
    * <P>
    public class AsapPublisher extends AsapCustomer {
    public static final String CLASS_NAME= "AsapPublisher";
    public static final String PUBLISHER_CONTACT= "AsapPublisherContact";
    public static final String PUBLISHER_DESCRIPTION="publisherDescription";
    private LibrarySession m_IfsSession= null;
    * Constructor
    public AsapPublisher( LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException{
    // Construct a Document object - standard variant.
    super(ifs,id,classId,data);
    m_IfsSession= ifs;
    public void setAsapPublisherContact(AsapPublisherContact newValue)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute(PUBLISHER_CONTACT, av);
    public void setAsapPublisherContact(AsapPublisherContactDef newValue)
    throws IfsException{
    PublicObject po= m_IfsSession.createPublicObject(newValue);
    AttributeValue av= AttributeValue.newAttributeValue(po);
    setAttribute(PUBLISHER_CONTACT, av);
    public void setPublisherDescription(String newValue)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute(PUBLISHER_DESCRIPTION, av);
    public String getPublisherDescription()
    throws IfsException{
    AttributeValue av= getAttribute(PUBLISHER_DESCRIPTION);
    return av.getString(getSession());
    public AsapPublisherContact getAsapPublisherContact()
    throws IfsException{
    AttributeValue av= getAttribute(PUBLISHER_CONTACT);
    return (AsapPublisherContact)av.getObject(getSession());
    AsapPublisherDef.jav
    // Copyright (c) 2000 Thin Data Solutions
    package publishasap;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import oracle.ifs.server.S_LibraryObjectData;
    import publishasap.AsapCustomer;
    import publishasap.AsapPublisherContact;
    import publishasap.definition.AsapPublisherContactDef;
    * A Bean class.
    * <P>
    public class AsapPublisher extends AsapCustomer {
    public static final String CLASS_NAME= "AsapPublisher";
    public static final String PUBLISHER_CONTACT= "AsapPublisherContact";
    public static final String PUBLISHER_DESCRIPTION="publisherDescription";
    private LibrarySession m_IfsSession= null;
    * Constructor
    public AsapPublisher( LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException{
    // Construct a Document object - standard variant.
    super(ifs,id,classId,data);
    m_IfsSession= ifs;
    public void setAsapPublisherContact(AsapPublisherContact newValue)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute(PUBLISHER_CONTACT, av);
    public void setAsapPublisherContact(AsapPublisherContactDef newValue)
    throws IfsException{
    PublicObject po= m_IfsSession.createPublicObject(newValue);
    AttributeValue av= AttributeValue.newAttributeValue(po);
    setAttribute(PUBLISHER_CONTACT, av);
    public void setPublisherDescription(String newValue)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute(PUBLISHER_DESCRIPTION, av);
    public String getPublisherDescription()
    throws IfsException{
    AttributeValue av= getAttribute(PUBLISHER_DESCRIPTION);
    return av.getString(getSession());
    public AsapPublisherContact getAsapPublisherContact()
    throws IfsException{
    AttributeValue av= getAttribute(PUBLISHER_CONTACT);
    return (AsapPublisherContact)av.getObject(getSession());
    AsapPublisherContact.java
    // Copyright (c) 2000 Movement Inc.
    package publishasap;
    import publish asap.*;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import oracle.ifs.server.S_LibraryObjectData;
    * A Bean class.
    * <P>
    public class AsapPublisherContact extends AsapPerson {
    public static final String PUBLISHER_ID= "publisherId";
    public static final String JOB_TITLE= "jobTitle";
    public static final String CLASS_NAME= "AsapPublisherContact";
    * Constructor
    public AsapPublisherContact( LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException{
    // Construct a Document object - standard variant.
    super(ifs,id,classId,data);
    public void setPublisherId(String newId)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newId);
    setAttribute(PUBLISHER_ID, av);
    public void setJobTitle(String newTitle)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newTitle);
    setAttribute(JOB_TITLE, av);
    public String getPublisherId()
    throws IfsException{
    AttributeValue av= getAttribute(PUBLISHER_ID);
    return av.getString(getSession());
    public String getJobTitle()
    throws IfsException{
    AttributeValue av= getAttribute(JOB_TITLE);
    return av.getString(getSession());
    AsapPublisherContactDef.java
    // Copyright (c) 2000 Movement Inc.
    package publishasap.definition;
    import publishasap.AsapPublisherContact;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    * A Bean class.
    * <P>
    public class AsapPublisherContactDef extends AsapPersonDef {
    * Constructor
    public AsapPublisherContactDef(LibrarySession ifs)
    throws IfsException
    // Construct a Document object - standard variant.
    super(ifs);
    this.setClassObject(ClassObject.getClassObjectFromLabel(ifs,publishasap.AsapPublisherContact.CLASS_NAME));
    public void setPublisherId(String newId)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newId);
    setAttribute(AsapPublisherContact.PUBLISHER_ID, av);
    public void setJobTitle(String newTitle)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newTitle);
    setAttribute(AsapPublisherContact.JOB_TITLE, av);
    AsapPublisherContact.xml
    <ClassObject>
    <Name>AsapPublisherContact</Name>
    <Description>Stores the information on the main contact person for the publisher.</Description>
    <SuperClass RefType="name">AsapPerson</SuperClass>
    <BeanClassPath>publishasap.AsapPublisherContact</BeanClassPath>
    <!-- Attribute list for the object -->
    <Attributes>
    <!-- Store the primary key of the publisher whom this person is the contact for. -->
    <Attribute>
    <Name>publisherId</Name>
    <DataType>String</DataType>
    <DataLength>10</DataLength>
    </Attribute>
    <!-- Store the contact person's job title or position. -->
    <Attribute>
    <Name>jobTitle</Name>
    <DataType>String</DataType>
    <DataLength>70</DataLength>
    </Attribute>
    </Attributes>
    </ClassObject>
    AsapPublisher.xml
    <ClassObject>
    <Name>AsapPublisher</Name>
    <Description>Stores the information about publishers in the database.</Description>
    <SuperClass RefType="name">AsapCustomer</SuperClass>
    <BeanClassPath>publishasap.AsapPublisher</BeanClassPath>
    <!-- Attribute list for the object. -->
    <Attributes>
    <!-- A reference to the main contact person at the publisher. -->
    <Attribute>
    <Name>asapPublisherContact</Name>
    <DataType>PublicObject</DataType>
    <ClassDomain reftype="name">AsapPubContactDomain</ClassDomain>
    </Attribute>
    <!-- A Descript ion of the publisher. -->
    <Attribute>
    <Name>publisherDescription</Name>
    <DataType>String</DataType>
    <DataLength>500</DataLength>
    </Attribute>
    </Attributes>
    </ClassObject>
    stack trace
    System was unable to create an author object oracle.ifs.common.IfsException: IFS-30002: Unable to create new LibraryObject oracle.ifs.common.IfsException: IFS-10407: Invalid Attribute name (JOBTITLE) at oracle.ifs.server.S_LibraryObject.insertRows(S_LibraryObject.java, Compiled Code) at oracle.ifs.server.OperationState.executeAtomicOperations(OperationState.java, Compiled Code) at oracle.ifs.server.S_LibraryObject.createInstance(S_LibraryObject.java, Compiled Code) at oracle.ifs.server.S_LibrarySession.newLibraryObject(S_LibrarySession.java, Compiled Code) at oracle.ifs.server.S_LibrarySession.newPublicObject(S_LibrarySession.java:6853) at oracle.ifs.server.S_LibrarySession.newPublicObject(S_LibrarySession.java:6835) at oracle.ifs.server.S_LibrarySession.DMNewPublicObject(S_LibrarySession.java:6623) at oracle.ifs.beans.LibrarySession.DMNewPublicObject(LibrarySession.java:7226) at oracle.ifs.beans.LibrarySession.NewPublicObject(LibrarySession.java:4795) at oracle.ifs.beans.LibrarySession.createPublicObject(LibrarySession.java:2789) at publishasap.definition.AsapPublisherDef.setAsapPublisherContact(AsapPublisherDef.java:41) at ifs.files._ifs._jsp_25_2dbin._admin._instantiatePublisher._jspService(_instantiatePublisher.java:166) at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java, Compiled Code) at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java, Compiled Code) at oracle.jsp.JspServlet.doDispatch(JspServlet.java, Compiled Code) at oracle.jsp.JspServlet.internalService(JspServlet.java, Compiled Code) at oracle.ifs.protocols.dav.impl.IfsDavServlet.processJsp(IfsDavServlet.java, Compiled Code) at oracle.ifs.protocols.dav.impl.IfsDavServlet.doGet(IfsDavServlet.java, Compiled Code) at oracle.ifs.protocols.dav.impl.IfsDavServlet.doPost(IfsDavServlet.java, Compiled Code) at oracle.ifs.protocols.dav.DavServlet.processRequest(DavServlet.java, Compiled Code) at oracle.ifs.protocols.dav.DavServlet.service(DavServlet.java, Compiled Code) at oracle.ifs.protocols.dav.impl.IfsDavServlet.service(IfsDavServlet.java, Compiled Code) at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code) at org.apache.jserv.JServConnection.processRequest(JServConnection.java, Compiled Code) at org.apache.jserv.JServConnection.run(JServConnection.java, Compiled Code) at java.lang.Thread.run(Thread.java, Compiled Code) IFS-30002: Unable to create new LibraryObject

    Sorry Mark. Here are the rest of the files.
    AsapPerson.java
    // Copyright (c) 2000 PublishASAP
    package publishasap;
    import oracle.ifs.beans.ApplicationObject;
    import oracle.ifs.beans.LibrarySession;
    import oracle.ifs.common.AttributeValue;
    import oracle.ifs.common.IfsException;
    import oracle.ifs.server.S_LibraryObjectData;
    * Superclass of all people involved in Publishasap
    * <P>
    public class AsapPerson extends ApplicationObject {
    // Private class constants.
    public static final String CLASS_NAME = "AsapPerson";
    public static final String PREFIX= "prefix";
    public static final String FIRST_NAME= "firstName";
    public static final String INITIAL= "mInitial";
    public static final String LAST_NAME= "lastName";
    public static final String SUFFIX = "suffix";
    public static final String EMAIL_ONE= "email1";
    public static final String EMAIL_TWO= "email2";
    public static final String WORK_PHONE= "wkPhone";
    public static final String FAX= "fax";
    public static final String USERNAME= "username";
    public static final String PASSWORD= "password";
    * Constructor
    public AsapPerson(LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException{
    super(ifs, id, classId, data);
    * Set the value of the PREFIX attribute.
    public final void setPrefix( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( PREFIX, av );
    * Get the current value of the PREFIX attribute.
    public final String getPrefix()
    throws IfsException{
    AttributeValue av= getAttribute(PREFIX);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the first name attribute.
    public final void setFirstName( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( FIRST_NAME, av );
    * Get the current value of the FIRST_NAME attribute.
    public final String getFirstName()
    throws IfsException{
    AttributeValue av= getAttribute(FIRST_NAME);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the INITIAL attribute.
    public final void setMInitial( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( INITIAL, av );
    * Get the current value of the INITIAL attribute.
    public final String getMInitial()
    throws IfsException{
    AttributeValue av= getAttribute(INITIAL);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the LAST_NAME attribute.
    public final void setLastName( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( LAST_NAME, av );
    * Get the current value of the LAST_NAME attribute.
    public final String getLastName()
    throws IfsException{
    AttributeValue av= getAttribute(LAST_NAME);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the SUFFIX attribute.
    public final void setSuffix( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( SUFFIX, av );
    * Get the current value of the SUFFIX attribute.
    public final String getSuffix()
    throws IfsException{
    AttributeValue av= getAttribute(SUFFIX);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the EMAIL_ONE attribute.
    public final void setEmail1( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( EMAIL_ONE, av );
    * Get the current value of the EMAIL_ONE.
    public final String getEmail1()
    throws IfsException{
    AttributeValue av= getAttribute(EMAIL_ONE);
    String tmp= av.getString(getSession());
    return t mp.trim();
    * Set the EMAIL_TWO attribute.
    public final void setEmail2( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( EMAIL_TWO, av );
    * Get the current value of EMAIL_TWO.
    public final String getEmail2()
    throws IfsException{
    AttributeValue av= getAttribute(EMAIL_TWO);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the WORK_PHONE attribute.
    public final void setWkPhone( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( WORK_PHONE, av );
    * Get the current value of the WORK_PHONE attribute.
    public final String getWkPhone()
    throws IfsException{
    AttributeValue av= getAttribute(WORK_PHONE);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the FAX attribute.
    public final void setFax( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( FAX, av );
    * Get the current value of the FAX attribute.
    public final String getFax()
    throws IfsException{
    AttributeValue av= getAttribute(FAX);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the username and password.
    public final void setUsername( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( USERNAME, av );
    * Get the current value of the USERNAME.
    public final String getUsername()
    throws IfsException{
    AttributeValue av= getAttribute(USERNAME);
    String tmp= av.getString(getSession());
    return tmp.trim();
    * Set the value of the PASSWORD attribute.
    public final void setPassword( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( PASSWORD, av );
    * Get the current value of the password field.
    public final String getPassword()
    throws IfsException{
    AttributeValue av= getAttribute(PASSWORD);
    String tmp= av.getString(getSession());
    return tmp.trim();
    AsapPersonDef.java
    // Copyright (c) 2000 Movement Inc
    package publishasap.definition;
    import oracle.ifs.beans.ClassObject;
    import oracle.ifs.beans.LibrarySession;
    import oracle.ifs.beans.LibraryObjectDefinition;
    import oracle.ifs.beans.ApplicationObjectDefinition;
    import oracle.ifs.common.AttributeValue;
    import oracle.ifs.common.IfsException;
    import javax.servlet.http.HttpServletRequest;
    import oracle.ifs.beans.DocumentDefinition;
    * A Bean class.
    * <P>
    * @author Brooke Supryka
    public class AsapPersonDef extends ApplicationObjectDefinition {
    * This bean is called to create an instance of a person
    * <P>
    * @author Brooke Supryka
    private static final boolean DEBUG = true;
    * Constructs a new instance.
    public AsapPersonDef(LibrarySession ifs) throws IfsException
    //Construct an AsapAuthor object
    super(ifs);
    this.setClassObject(ClassObject.getClassObjectFromLabel(ifs,publishasap.AsapPerson.CLASS_NAME));
    * Set the value of the PREFIX attribute.
    public final void setPrefix( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( publishasap.AsapPerson.PREFIX, av );
    * Set the value of the first name attribute.
    public final void setFirstName( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( publishasap.AsapPerson.FIRST_NAME, av );
    * Set the value of the INITIAL attribute.
    public final void setMInitial( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( publishasap.AsapPerson.INITIAL, av );
    * Set the value of the LAST_NAME attribute.
    public final void setLastName( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( publishasap.AsapPerson.LAST_NAME, av );
    * Set the value of the SUFFIX attribute.
    public final void setSuffix( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue( newValue );
    setAttribute( publishasap.AsapPerson.SUFFIX, av );
    * Set the EMAIL_ONE attribute.
    public final void setEmail1( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.EMAIL_ONE, av );
    * Set the EMAIL_TWO attribute.
    public final void setEmail2( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.EMAIL_TWO, av );
    * Set the value of the WORK_PHONE attribute.
    public final void setWkPhone( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.WORK_PHONE, av );
    * Set the value of the FAX attribute.
    public final void setFax( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.FAX, av );
    * Set the value of the username and password.
    public final void setUsername( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.USERNAME, av );
    * Set the value of the PASSWORD attribute.
    public final void setPassword( String newValue )
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newValue);
    setAttribute( publishasap.AsapPerson.PASSWORD, av );
    AsapCustomer
    // Copyright (c) 2000 Movement Inc.
    package publishasap;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import oracle.ifs.server.S_LibraryObjectData;
    * Instance of AsapCustomer.
    * <P>
    * @author Ian Kulmatycki
    public class AsapCustomer extends TieApplicationObject {
    public static final String CLASS_NAME= "AsapCustomer";
    public static final String COMPANY_NAME= "companyName";
    public static final String ADDRESS_1= "address1";
    public static final String ADDRESS_2= "address2";
    public static final String CITY= "city";
    public static final String STATE= "state";
    public static final String POSTAL_CODE= "postalCode";
    public static final String PHONE_NUMBER= "phoneNumber";
    public static final String COUNTRY= "country";
    * Constructor
    public AsapCustomer( LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException{
    // Construct a Document object - standard variant.
    super(ifs,id,classId,data);
    public void setCompanyName(String newName)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newName);
    setAttribute(COMPANY_NAME, av);
    public void setAddress1(String newAddress)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newAddress);
    setAttribute(ADDRESS_1, av);
    public void setAddress2(String newAddress)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newAddress);
    setAttribute(ADDRESS_2, av);
    public void setCity(String newCity)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newCity);
    setAttribute(CITY, av);
    public void setState(String newState)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newState);
    setAttribute(STATE, av);
    public void setPostalCode(String newPostalCode)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newPostalCode);
    setAttribute(POSTAL_C ODE, av);
    public void setCountry(String newCountry)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newCountry);
    setAttribute(COUNTRY, av);
    public void setPhoneNumber(String newPhoneNumber)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newPhoneNumber);
    setAttribute(PHONE_NUMBER, av);
    public String getCompanyName()
    throws IfsException{
    AttributeValue av= getAttribute(COMPANY_NAME);
    return av.getString(getSession());
    public String getAddress1()
    throws IfsException{
    AttributeValue av= getAttribute(ADDRESS_1);
    return av.getString(getSession());
    public String getAddress2()
    throws IfsException{
    AttributeValue av= getAttribute(ADDRESS_2);
    return av.getString(getSession());
    public String getCity()
    throws IfsException{
    AttributeValue av= getAttribute(CITY);
    return av.getString(getSession());
    public String getPostalCode()
    throws IfsException{
    AttributeValue av= getAttribute(POSTAL_CODE);
    return av.getString(getSession());
    public String getCountry()
    throws IfsException{
    AttributeValue av= getAttribute(COUNTRY);
    return av.getString(getSession());
    public String getState()
    throws IfsException{
    AttributeValue av= getAttribute(STATE);
    return av.getString(getSession());
    public String getPhoneNumber()
    throws IfsException{
    AttributeValue av= getAttribute(PHONE_NUMBER);
    return av.getString(getSession());
    AsapCustomerDef.java
    // Copyright (c) 2000 Movement Inc.
    package publishasap.definition;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import publishasap.AsapCustomer;
    * Create the definition for an AsapCustomer object.
    * <P>
    * @author Ian Kulmatycki
    public class AsapCustomerDef extends ApplicationObjectDefinition {
    * Constructor
    public AsapCustomerDef(LibrarySession ifs)
    throws IfsException
    // Construct a Document object - standard variant.
    super(ifs);
    this.setClassObject(ClassObject.getClassObjectFromLabel(ifs,publishasap.AsapCustomer.CLASS_NAME));
    public void setCompanyName(String newName)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newName);
    setAttribute(AsapCustomer.COMPANY_NAME, av);
    public void setAddress1(String newAddress)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newAddress);
    setAttribute(AsapCustomer.ADDRESS_1, av);
    public void setAddress2(String newAddress)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newAddress);
    setAttribute(AsapCustomer.ADDRESS_2, av);
    public void setCity(String newCity)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newCity);
    setAttribute(AsapCustomer.CITY, av);
    public void setState(String newState)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newState);
    setAttribute(AsapCustomer.STATE, av);
    public void setPostalCode(String newPostalCode)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newPostalCode);
    setAttribute(AsapCustomer.POSTAL_CODE, av);
    public void setCountry(String newCountry)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newCountry);
    setAttribute(AsapCustomer.COUNTRY, av);
    public void setPhoneNumber(String newPhoneNumber)
    throws IfsException{
    AttributeValue av= AttributeValue.newAttributeValue(newPhoneNumber);
    setAttribute(AsapCustomer.PHONE_NUMBER, av);
    AsapPerson.xml
    <?xml version = '1.0' standalone = 'yes'?>
    <!-- AsapPerson.xml -->
    <ClassObject>
    <Name>AsapPerson</Name>
    <Description>AsapPerson Object</Description>
    <Superclass Reftype = "name">ApplicationObject</Superclass>
    <BeanClassPath>publishasap.AsapPerson</BeanClassPath>
    <Attributes&gt ;
    <Attribute>
    <Name>prefix</Name>
    <DataType>String</DataType>
    <DATALENGTH>4</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>firstName</Name>
    <DataType>String</DataType>
    <DATALENGTH>30</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>mInitial</Name>
    <DataType>String</DataType>
    <DATALENGTH>1</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>lastName</Name>
    <DataType>String</DataType>
    <DATALENGTH>30</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>suffix</Name>
    <DataType>String</DataType>
    <DATALENGTH>4</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>email1</Name>
    <DataType>String</DataType>
    <DATALENGTH>50</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>email2</Name>
    <DataType>String</DataType>
    <DATALENGTH>50</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>fax</Name>
    <DataType>String</DataType>
    <DATALENGTH>20</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>wkPhone</Name>
    <DataType>String</DataType>
    <DATALENGTH>20</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>username</Name>
    <DataType>String</DataType>
    <DATALENGTH>15</DATALENGTH>
    </Attribute>
    <Attribute>
    <Name>password</Name>
    <DataType>String</DataType>
    <DATALENGTH>15</DATALENGTH>
    </Attribute>
    </Attributes>
    </ClassObject>
    AsapCustomer.xml
    <?xml version="1.0" standalone="yes"?>
    <!-- AsapCustomer.xml -->
    <!-- When parsed, this file will create the definition of an AsapCustomer in the database. -->
    <ClassObject>
    <Name>AsapCustomer</Name>
    <Description>Parent of all customers that are using Publishasap.</Description>
    <SuperClass RefType="name">ApplicationObject</SuperClass>
    <BeanClassPath>publishasap.AsapCustomer</BeanClassPath>
    <!-- Attribute list for the object. -->
    <Attributes>
    <!-- The company name of the customer. -->
    <Attribute>
    <Name>companyName</Name>
    <DataType>String</DataType>
    <DataLength>75</DataLength>
    </Attribute>
    <!-- The mailing address of the customer. -->
    <Attribute>
    <Name>address1</Name>
    <DataType>String</DataType>
    <DataLength>50</DataLength>
    </Attribute>
    <!-- The secondary mailing address of the customer. -->
    <Attribute>
    <Name>address2</Name>
    <DataType>String</DataType>
    <DataLength>50</DataLength>
    </Attribute>
    <!-- The mailing city of the customer. -->
    <Attribute>
    <Name>city</Name>
    <DataType>String</DataType>
    <DataLength>30</DataLength>
    </Attribute>
    <!-- The mailing state of the customer. -->
    <Attribute>
    <Name>state</Name>
    <DataType>String</DataType>
    <DataLength>4</DataLength>
    </Attribute>
    <!-- The mailing postal code of the customer. -->
    <Attribute>
    <Name>postalCode</Name>
    <DataType>String</DataType>
    <DataLength>10</DataLength>
    </Attribute>
    <!-- The contact phone number of the customer. -->
    <Attribute>
    <Name>phoneNumber</Name>
    <DataType>String</DataType>
    <DataLength>14</DataLength>
    </Attribute>
    <!-- The mailing country of the customer. -->
    <Attribute>
    <Name>country</Name>
    <DataType>String</DataT ype>
    <DataLength>30</DataLength>
    </Attribute>
    </Attributes>
    </ClassObject>
    null

  • Another Inheritance Question, please help.

    Below is a setup of two packages and three classes:
    package com.foo.package1
    * This is the main superclass.
    public class SuperClass extends Object {
        public SuperClass () {
        protected getFoo() {
            return "foo";
    }here is the second package:
    package com.foo.package2
    import com.foo.package1.SuperClass;
    * This class extends SuperClass. Obviously, I removed
    * all methods for brevity.
    public class SubClass extends SuperClass {
        public SubClass () {
            super();
    * This class extends SubClass. A method here is supposed to
    * create an instance of the SuperClass and call a method on it.
    * In this case, {SuperClass#getFoo()} is called.
    public class SubSubClass extends SubClass {
        public SubSubClass () {
            super();
        public void method() {
            SubClass sc = new SubClass();
            System.out.println (
                    sc.getFoo());
    }Now why do I get a compile exception "getFoo() has protected access in com.foo.package1.SuperClass"? Should that be the case?
    Thanks in advance.
    Georg.

    It isn't a bug. Saying that protected members of a class are accessible from subclasses is not exactly true.
    From the JLS: 6.6.2 Details on protected Access
    A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
    SubSubClass is not responsible for the implementation of SuperClass. So basically, a class can only have access to protected members defined in a superclass if either:
    a) it is in the same package
    - or -
    b) the type of the reference used to access those members is that class, or one of it's subclasses.

  • [svn] 4932: Fixed RTE with FxAnimate3DInstance, where a check in a superclass on whether the property was a style didn' t succeed because the effect was using properties that weren' t actually styles or properties on the object.

    Revision: 4932
    Author: [email protected]
    Date: 2009-02-11 15:29:32 -0800 (Wed, 11 Feb 2009)
    Log Message:
    Fixed RTE with FxAnimate3DInstance, where a check in a superclass on whether the property was a style didn't succeed because the effect was using properties that weren't actually styles or properties on the object. Fine for the effect, but not for the superclass. Fix was to simply stub out the style check.
    QE Notes:
    Doc Notes: None
    Bugs: SDK-19256
    Reviewer: Ely
    tests: checkintests, Mustella mx/effects/FxRotate3D
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-19256
    Modified Paths:
    flex/sdk/branches/i10/frameworks/projects/flex4/src/mx/effects/effectClasses/FxAnimate3DI nstance.as

    Revision: 4932
    Author: [email protected]
    Date: 2009-02-11 15:29:32 -0800 (Wed, 11 Feb 2009)
    Log Message:
    Fixed RTE with FxAnimate3DInstance, where a check in a superclass on whether the property was a style didn't succeed because the effect was using properties that weren't actually styles or properties on the object. Fine for the effect, but not for the superclass. Fix was to simply stub out the style check.
    QE Notes:
    Doc Notes: None
    Bugs: SDK-19256
    Reviewer: Ely
    tests: checkintests, Mustella mx/effects/FxRotate3D
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-19256
    Modified Paths:
    flex/sdk/branches/i10/frameworks/projects/flex4/src/mx/effects/effectClasses/FxAnimate3DI nstance.as

  • Understanding Java superclass hierarchy through System objects and methods

    I wanted to see if I can manipulate datastreams manually rather than relying on classes.
    I knew that System.in was an InputStream object so it must use the said methods such as System.in.read()
    I made a program for it. It gave me an IOException. When I went to "catch" the exception it said cannot find symbol IOException. This was fixed by import java.io.*;
    I find that very weird conceptually. First System.in is wrapped by the System class. I have no need to import java.io.*; to use System so why would I need to import it in this case. Second, when I use Scanner to read in from System.in I do need to import java.io.*, yet I'm pretty sure it makes the same method calls to System.in I make, no?
    //import java.io.*;
    public class streams
         public static void main( String[] args )
              try {
                   System.out.printf( "%c\n", System.in.read() );
              } catch (IOException e) {
                   System.err.println( "IOException error" );
    }

    Importing does not make classes available. All it does is tell the compiler that when you say "IOException," it is actually shorthand for "java.io.IOException." The import applies only to the class in which it is declared, and only at compile time. It is gone once you compile your class. It does not show up in the .class file, and has no effect whatsoever at runtime.

  • Hook methods in ABAP Objects

    Hello,
    i discovered that method calling in the class-inheritance of ABAP Objects doesn't work similar to other OO languages.
    Example:
    1 Superclass named "Z_CLASS"
    1 Subclass of "Z_CLASS" named "Z_SUB"
    Z_CLASS defines a method "initialize" and has a constructor which calls "initialize".
    Z_SUB redefines the method "initialize" assigning some values to instance-attributes.
    If i instantiate a new "Z_SUB"-object then the contructor of "Z_CLASS" is called which calls ITS OWN "initialize" not the one of the subclass. For comparison: Java would call the initialize of the subclass.
    I have to implement a constructor in every subclass of "Z_CLASS" which calls the super constructor and the own "initialize" after that to solve this problem. This isn't the proper OO way!
    Did i miss something or am i right?
    Thanks in advance,
    Stefan

    Check out this, it might be helpfull...
          INTERFACE I_COUNTER
    INTERFACE i_counter.
      METHODS: initialize.
    ENDINTERFACE.
          CLASS C_COUNTER1 DEFINITION
    CLASS c_counter1 DEFINITION.
      PUBLIC SECTION.
        INTERFACES i_counter.
        METHODS: constructor.
        DATA count TYPE i.
    ENDCLASS.
          CLASS C_COUNTER1 IMPLEMENTATION
    CLASS c_counter1 IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD me->i_counter~initialize.
      ENDMETHOD.
      METHOD i_counter~initialize.
        count = count + 10.
        write:/ 'count from super', count.
      ENDMETHOD.
    ENDCLASS.
          CLASS C_COUNTER2 DEFINITION
    CLASS c_counter2 DEFINITION INHERITING FROM c_counter1.
      PUBLIC SECTION.
        METHODS: constructor,
                 initialize.
        DATA count1 TYPE i.
    ENDCLASS.
          CLASS C_COUNTER2 IMPLEMENTATION
    CLASS c_counter2 IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor.
        CALL METHOD me->initialize.
      ENDMETHOD.
      METHOD initialize.
        count = ( count / 10 ).
        write:/ 'count from sub', count.
      ENDMETHOD.
    ENDCLASS.
    DATA: count TYPE REF TO c_counter2.
    START-OF-SELECTION.
    CREATE OBJECT count TYPE c_counter2.

  • Overriding attributes in ABAP objects

    Hello,
    I currently want know if it is possible to override attributes in ABAP objects. i know it is possible with methods. I have extend a previous class functionality and want to change the refrence type of an attribute from the parent class, but only on the child. Is this possible in ABAP object or even in normal object oriented techniques.
    Thanks
    Brendan

    Hi,
    ususally you can achive this with other technics. You can e.g. use the class hierarchy for this:
    The attribute is of type REF_SUPERCLASS. Within the superclass it should be working when you set subclasses of REF_SUPERCLASS as attribute.
    Another way is to use interfaces as reference type for your attribute.
    Please refer to [ABAP Objects|http://help.sap.com/saphelp_nw70/helpdata/EN/ce/b518b6513611d194a50000e8353423/frameset.htm]. Especially the chapters about Inheritance and Interfaces.
    Regards Rudi

  • Order of Object Creation

    I need to know what order various objects are created and processed. An example will be most helpful.
    class A {
    A() { myFunc();    }
    public void myFunc() {}
    class B extends A {
    class innerB {       public void funcInnerB() { ... do some work ...       } }
    public void myFunc() {       someVar.funcInnerB();   }
    innerB someVar = new innerB();
    When class B is instantiated the following happens [assuming I coded my example properly :) ]
    1. The default B constructor is called.
    2. It calls the A constructor.
    3. The method myFunc in class B is called from A constructor.
    4. a NULL Pointer error occurs because someVar has appearantly not yet been assigned to the new innerB object.
    This is my problem, why is someVar not being created immediately? I don't know if this problem is universal, but in my particular application, it is happening this way. (I can't post the actual code, because it is way, way too long.)
    I tried using an initialization block in class B to assign someVar, but the same problem occurs.
    Here's my current workaround:
    in class B:
    public void myFunc() {  if (someVar == null) { someVar = new innerB() }
    someVar.funcInnerB(); }
    But I am hoping there is a better solution and I am worried about when I may run into this situation. So, I am hoping there is a definitive guide to the order everything is created.
    Thanks in advance.

    It's not a good idea to call non-final methods from a non-final class because of exactly what you found. The NullPointerException happens because of the order of processing that you described - by the time you get to B.myFunc(), the B members have not been initialized. First, the superclass is fully initialized. All members are set to their initial values, then the constructor is executed. After the superclass constructor finishes, then the subclass members are initialized, and any further subclass constructor processing occurs.

  • Instantiation of new objects - a beginners cry for help!!!

    Hi - i am working through (on no not another bloody Bank Account) problem. It is the same problem posted in this topic - http://forum.java.sun.com/thread.jsp?forum=31&thread=308754
    where the author was roundly slated for not even having a go.
    I am not asking for someone to complete the program but would like to be kicked off again having ground to a halt.
    I had decided to create a Parent Bank Account class and then create child classes for Current, Platinum and Student Accounts. I am very unsure as to how to then create the methods that will allow the user to, for instance, check the balance, deposit an amount etc. While I am generally comfortable with While/Do's and Else/If's, Im still very rusty with the terminology and instantiation of objects that users can manipulate (having never yet created a working program!).
    Please read what I've done so far and then I would be msot grateful for pointers. Or if you want to slate me then at least make it funny!
    public class bankAccount { //Declares superclass
    private String name; //Account Holder Name
    private int accNo; //Account Number
    private String accType; //Type of Account
    private int balance; //Balance
    private int deposit; //Depost
    private int withdrawal; //Withdrawal
    private boolean overdrawn; // Overdrawn or in Credit?
    public bankAccount() {} // Default constructor
    public bankAccount(String n, int a) { //Constructor #1
    name = n;
    accNo = a;
    deposit = false;
    withdrawal = false;
    public bankAccount(String n, int a, boolean d, boolean w) {//Constructor #2
    name = n;
    AccNo = a;
    deposit = d;
    withdrawal = w;
    public String getName() { //get() and set () methods
    return name;
    public void setName(String n){
    name = n;
    public int getAccNo(){
    return accNo;
    public void setAccNo(int accNo){
    accNo = a;
    public String getAccType(){
    return accType;
    public void setAccType(String at){
    accType = at}
    public int getBalance(){
    return balance;
    public void setBalance(int b){
    balance = b;
    public int getDeposit(){
    return deposit;
    public void setDeposit(int d){
    deposit = d;
    public int getWithdrawal(){
    return withdrawal;
    public void setWithdrawal(int w){
    withdrawal = w;
    public boolean getOverdrawn(){
    return overdrawn;
    public void setOverdrawn(boolean o){
    overdrawn = o;
    public void printOut(){
    System.out.println (name + accNo + accType + balance + deposit + withdrawal+
    overdrawn);
    } //end of bankAccount class
    public class Current extends BankAccount {//Current Account class derived from Bank Account class
    public current () {} //empty method for default constructor
    public current (String n, int a, boolean a, boolean w){
    setname(n);
    setaccNo(a);
    set deposit(false);
    set withdrawal(false); //this is as far as I got before punching the computer!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    You've gotta give him credit though, he did try. apparently didn't work, must be caps sensitive.
    And Barty1... remember to close your code brackets, otherwise it tends to chop off the last 2 lines or so.
    Cheers,
    Radish21                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • IPod Mini need help!

    Hello everybody! Lately, I have been having trouble with my pink iPod Mini (1st generation). I was updating my iPod Mini with the latest restore, and it completed, and required me to plug the ipod into an external power charger. I was not at home, an

  • AUDIO; what can i do to fix this?

    sometimes when i watch youtube videos or any videos that stream online like hulu, the audio messes up with the visual part of the video and a good portion of the video is muted and jumps forward, what can i do to fix this?

  • Smartform form {T_HEADER} has wrong page format

    I have a header window that contains a table for column headings just above my main window.  Somehow in the process of inserting a column and adjusting the size, I caused the following error to continue each time I attempt to print preview the form:

  • Photoshop CS5 crashes only minutes after loading up

    My dad just recently purchased Adobe Photoshop CS5 for me, and I installed it about 2 days ago. I installed the program 3 times without any different results. After loading up, it runs fine, I'm able to do a little sketch. However, after about 5 minu

  • Is it possible to get Remote Desktop Services running when in Sysprep Audit mode in 2012r2?

    Hi, I'm setting up some images for 2012r2 and personally like to be able to access the machines via RDP. I have broken out of the OOBE by pressing CTRL+SHIFT+F3, however, even though RDP is enabled (System --> Remote Setting) and running (Services --