Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

System Thread  RSS feed

 
amal shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
we all know that the main method is first called when a java application is executed. To execute that i believe a Thread is been created by jvm assumably called as System Thread,which executes the main method. Going by assuming this concept,how does the following code produces o/p as 6793



help appreciated
cheers
amal shah
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how does the following code produces o/p as 6793


The "6" is printed when the test class is loaded, obviously before the main() method is called.

The "7" is printed by line one of the main() method.

The "9" is printed by line three of the main() method.

The "3" is printed by the constructor, when a test object is created by line four of the main() method.

Henry
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!