If i have the following scenario:
public class Foo extends Baz{
private String banana = "banana";
//blah blah blah
}
public class Baz{
protected static String apple = "apple";
}
Which get created first, apple or banana? I want to say apple gets created first, but I am not sure.
appleis created first. It is static, and in the parent level class.The static initializer (which initializes the
applevariable) will run as soon as theBazclass is loaded which will have to happen before an instance ofBazcan be created.The intsance initializer (which initializes the
bananavariable) will run as soon as an instance ofFoois created.