Vaibhav Wahee

Ranch Hand
+ Follow
since Oct 30, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vaibhav Wahee

What i meant was if you run the following command ...

Java Main2 ...

The program displays HI as the output..implying that the main method which is of course static is indeed inherited by the Main2 class....

Please Comment On This
ok , here's another one...

This code compiles fine...which again proves beyond doubt that static methods are indeed inherited. I've seen mixed reviews and off the line answers.

Do we still have a doubt that static methods are not inherited ?

Please give a direct answer.... core question remains....


My example states that they are ....if someone thinks otherwise please explain why ?

This example above clearly states that a static method is indeed inherited but not overridden....but still i've found this to be true that many persons fail to recognise this fact that static methods are also inherited

Thanks for your reply and clarification. I never knew that a static is not barred from inheritance ...But the K&B books fails to mention this fact.....
I mean i was not able to extract this info from their SCJP 1.5 book

Still waiting for an opinion....

Can anyone please comment on this ?

Thanks marc for your prompt reply. But i did'nt get your point. How can a static method which is specific to Class Main2 be called upon a reference of it's subclass Main. Does this mean that static methods are indeed inherited ?

Thanks Irina for your reply...
But as far as i know that the static methods are not inherited as they are a part of the class but not a part of the any instance ? So don'nt you think it violates the definition of Static ?

Can anybody please comment on this works fine and displays the output as "In Main2's Static" i do not understand why...
Has this anything to do with inheritance please advise...

i am using net beans and why i try to run it says Main2 does not have a main methoid

i even tried to run the code on the command prompt but it gives error
"Exception in thread main java.lang.NoClassDefFoundError: Main2"

why so i don'nt know..

my java version is displayed above in this page
why do we need a code block to write new Main() in a class...
and this is fact is no where mentioned in K&B Book....
Sorry about the name glitch...i am now using my real name.
Thanks Manfred...for your prompt reply

But my version of java is Version 1.5.0 (build 1.5.0_09-b03) and the code mentioned in my question does'nt run...

and could you please tell what is mixed mode ?
Nope static methods are indeed inhertied...

for example