• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Initialization sequence

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all!

Can anyone one explain me initailization sequence i.e. for

static variable
static block
static method
constructors
instance variable
instance block
instance method

and same for super class if we instansiate a subclass's object.
What can we use as Constroctor's body?

thanks
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


When run, the following output is produced:



Local variables in static and non-static methods are of course only initialized when the method is called.
The order of execution of static blocks and static variable initialization is depending on the code, as far as I know!
[ July 23, 2008: Message edited by: Sid Murrey ]
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way if for you to simply try it for yourself!
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

there is a interesting topic about it on the 2nd page, take a look at it: https://coderanch.com/t/269520/java-programmer-SCJP/certification/initialization-sequence
 
reply
    Bookmark Topic Watch Topic
  • New Topic