The Output of below statement is correct because
((AClass)b).m(); // Does compile and return B\nSuper:\nA
There are two things happening
one is compile time polymorphism.
It's happening because you are doing BClass object type cast with AClass object so this thing checked at compile time.
second run time polymorphism.
At run time even you are using sub class object with super class reference it'll call sub class object method.
You are getting compile time error at
b.m(); // Does not compile
line because method m access modifier is protected and you can not use out of protected member out side the package without using inheritence.
Is there any body having idea how can i set maximum size for server log in jboss because my server log size is increasing frequently so i am unable to open it.
Please let me know if anybody is having idea about it.
static - any code block or instance constructor or method can set this so long as it has access
final - must be initialised at declaration, in a code block or in an constructor. Once initialised, it cannot be changed.
final int i;
public Test() {
i=15;
}
static final - must be initialised at declaration, or in a static code block. Once initialised, it cannot be changed (and that includes instance constructors).