#319 NullPointerException Thrown by Overriden Method

open
nobody
Parsing (77)
5
2008-08-29
2008-08-29
Anonymous
No

The following script throws NullPointerException.

import java.lang.Integer;
import java.sql.Timestamp;

public class A
{
public A (int id)
{
testMethod( "I" );
}

public void testMethod (String testString)
{
}

}

public class B extends A
{
public B ( int id )
{
super (id);
}

public void testMethod (String testString)
{
}
}

B mInOut = new B ( 0 );

By removing the testMethod() in constructor of A, it does not report anymore error. Why?

import java.lang.Integer;
import java.sql.Timestamp;

public class A
{
public A (int id)
{
// testMethod( "I" );
}

public void testMethod (String testString)
{
}

}

public class B extends A
{
public B ( int id )
{
super (id);
}

public void testMethod (String testString)
{
}
}

B mInOut = new B ( 0 );

Discussion

  • The subject of this should be:

    NullPointerException Thrown by Overridden Method

    Sorry about the typo.

    S.Poon
    http://www.bossmiles.net
    *** A Business Application User Community ***
    *** You Smile, I Smile and We All Smile! ***