Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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?
 
lowercase baba
Bartender
Posts: 12626
50
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.
 
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.
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!