Re: Overriding static methods : Whats wrong with these classes??
On Aug 10, 12:34 pm, Lew <no...@lewscanon.com> wrote:
ankur wrote:
package Pack1;
Side note: Java naming conventions call for package names to comprise all
lower-case characters. (In real life, package names that include varia=
tions
on "package" within their names do not make good names.)
public class SuperA {
public int supervarA;
Java naming conventions call for word parts within names to be capitalize=
d,
such as "superVarA". (In real life, "super" and "var" would be name pa=
rts to
avoid in a variable.)
public void superMethA()
{
System.out.println("Package Pack 1 Class SuperA"=
);
}
public static void methstaticA()
Likewise this should be named "methStaticA" by convention (except that in=
real
life "meth" and "static" would be name parts to avoid).
{
System.out.println("In class SuperA");
}
}
Further side note: do not use TAB characters to indent Usenet posts, use
spaces. Two (or up to four if you like) spaces are enough per indent l=
evel.
Usenet readers often have more restrictive width constraints than your
favorite source editor (although many folks recommend keeping source line=
s
limited in width, too). TABs tend to render posted code less readable,
hindering efforts to help you with your question.
--
Lew
Sorry to all for posting a vague question, not using the naming
convention and using tabs in usenet posts. I will avoid this going
forward. Coming to the question, all I was saying is that I was able
to override static method methstaticA() in SubD because it printed "In
class SubD" when called main(). If I comment out the definition for
methstaticA() in SubD then I would get "In class SuperA". In a way
didn't I override the static method ?? But I understand what Mike
Schilling's is saying in his post that polymorphic behavior cannot be
implemented by overriding static methods!
--
Thanks,
Ankur