• Post Reply Bookmark Topic Watch Topic
  • New Topic

Executes only once  RSS feed

 
sireesha vadlamani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, I just want to know in a java program, which field/block/statement is executed only once? and explain with an example.
Thanks.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sireesha vadlamani wrote:Hello guys, I just want to know in a java program, which field/block/statement is executed only once? and explain with an example.
Thanks.


I am going to guess that you got this question for something specific, and you are forwarding the question here -- with little or no context whatsoever.

Perhaps you can give us more details on what you are asking?

Henry
 
sireesha vadlamani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a program which field is executed only once either a constructor or main() or static fields??
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sireesha vadlamani wrote:In a program which field is executed only once either a constructor or main() or static fields??


A constructor is not a field.

A main() method is not a field.

A static field is a field, but what do you mean by executed once? Are you referring to the initialization of the field?

Henry
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would not take much effort to write a program that executes all of those multiple times, so I think the question as posed is misleading (or possibly a trick question).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!