• Post Reply Bookmark Topic Watch Topic
  • New Topic

For abstract public class , its "public static void main(String[] args) method executes.  RSS feed

 
Mangesh Kshirsagar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Abstract class can not be instantiated. However for code above, main method executes. Please explain how jvm handles this?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the main method is declared as static. Therefore, the method can be called regardless of an object of that type being created.

No ClassA is ever created.
 
Arun C. Giridharan
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch......





your not making an object over here .As soon .class file is loaded ....JVM will search for to get started ....... that's how it works ..... beside Java is quite smarter if i think about it ! ! !
 
Mangesh Kshirsagar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks for reply. Got distracted by abstract keyword and overlooked static keyword. Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!