Re: Who can tell me the initialzing sequence of a java programe?
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 22:19:37 -0400
Jack Dowson wrote:
abstract class A{
int i;
abstract void getInfo();
void print(){
System.out.println("print() int abstract class");
}
} class B extends A{
void getInfo(){
System.out.println("abstract method:getInfo() is implemented");
System.out.println("i =" + i);
}
}
public class AbstractClassDemo{
public static void main(String[] args){
B b = new B();
b.print();
b.getInfo();
}
}
The result is:
print() int abstract class
abstract method:getInfo() is implemented
i =0
My question is considering that method print in abstract class A is not a static method,then what happened to create the first sentence of the result("print() int abstract class")?
The line b.print();
Non-static 'print()', called via the instance pointed to by 'b', which in turn was created by 'new B()'. QED.
--
Lew
.
- Prev by Date: Re: The Scale problem
- Next by Date: Re: Clear Tomcat Classloader cache?
- Previous by thread: 3 java questions: debugging, templating and Swing app for Texts cleansing
- Next by thread: Re: Who can tell me the initialzing sequence of a java programe?
- Index(es):