What is the need for static block?

this was my interview question..
what is the scenario where u need a static block?

SO
public static String foo = "FOO";
and
static
public String foo="FOO";
both are static blocks?I don't know what the JLS says about that term. The second one is usually called a static initializer. I wouldn't consider the first one a block, but the JLS may say differently.
What is the difference between both?They're not quite the same.
public static String foo = "FOO";
// is equivalent to
public static String foo;
static {
  foo = Foo;
}Note that the variable must be declared outside the block to be a class member variable.
Now, consider the following, for which the static initializer block is necessary:
static ComplexThingummy ct;
static {
  try {
    ct = new ComplexThingrummy();
    ct.initializeSomethingSomehow();
  catch (CTCheckedException exc) {
    throw new ExceptionInInitializerError(exc);
    // OR
    ct = someDefaultPreInitializedComplexThingummy;
}

Similar Messages

  • What is the need for setting property data inside the JMSMesage

    Hi
    Could anybody please let me know
    *What is the need for setting property data inside the JMSMesage??
    For example i have a seen a similar example as shown ??
    I have seen a
    Message.setStringProperty("Sport","Basketball");
    and also please tell me how can the MDB recievies this property data ??
    Thanks in advance .

    raviprivate wrote:
    Could anybody please let me know
    *What is the need for setting property data inside the JMSMesage??
    For example i have a seen a similar example as shown ??
    I have seen a
    Message.setStringProperty("Sport","Basketball"); Look at the detail JMS documentation on [Message Properties|http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Message.html] .
    >
    and also please tell me how can the MDB recievies this property data ?? MDB onMessage method argument is the Message object and if you look at the documentation, Message interface has getter methods to retrieve the properties.

  • What is the need for calling default constructor by JVM?

    What is the need for calling default constructor by JVM? why the JVM should intiializes default values to the data
    fields if the constructor is not there in our class?

    mahar wrote:
    What is the need for calling default constructor by JVM? Huh? The JVM does not need to call the default constructor. It needs to call a constructor.
    You decide which one by the way you use "new".
    why the JVM should initialize default values to the data fieldsHuh?
    ... if the constructor is not there in our class?Huh? The default constructor is always there. It may be private but it is still there.

  • HT1222 Since I'm an American, what's the need for me to update?

    Since I'm an American, what's the need for me to update?
    How does the new update apply to me?

    What update are you referring to? If you mean iOS 6.1.3, there are a number of security updates that apply to all iOS devices:
    http://support.apple.com/kb/HT5704
    If that's not what you mean, please explain further.
    Regards.

  • What is the Need for communication between Flex ActionScript to Javascript

    Hi ,
    Flex has made it communication possible from FLEX Mx:script to Java Script .
    Can anybody could please tell me what is the need or any scenario  for communication Flex with Javascript
    Thanks in advance .

    1- Printing in Flex is terrible (although for simpler requirements it can do fine), true, but it's not incredibly better elsewhere in the browser unless I'm missing the point.  This can be gotten around for many by streaming PDFs or Excel spreadsheets from a server, though.
    2- If it has to be web, I guess you're stuck.  If it can be an installed app (AIR) I'd prefer to hook into Java.  Like I said, there may be some limited specific uses, but good reasons to base the majority of your app on JS hacks are hard to come by.

  • What is the need for movement type 107

    Hi Gurus,
    In ECC 6.0 i have seen that SAP has introduced 107 for GR Block stock (valuated). Can anyone tell me the business sense for doing so.
    What was the exact need for introducing 107
    Rgds
    Venkat

    Hi,
    GR Blocked valuatedstock menas , when you do the GR with movement type 107 it  will posted under Plant and the value of the goods will be considerd/increased for that Plant. But the stock will be under Blocked Stock..It will not be used all other purpose till you do the transfer psting from Blocked to unresticted.
    Thanks,
    Kumar Arcot

  • What's the need for capitalization date and 1st acq. posting date?

    hi guys,
    i was wondering what the system would do with capitalization date and first acquisition posting date ??
    and what will be the problem if i entered an asset value date (in the acquisition transaction) that's earlier than the capitalization date entered in the asset master record ?!

    In practice all assets are not put to use right from the date of purchase.Hence the concept of different dates arises.  One being the acquisition date and the other Capitalization date.
    I would buy an asset today but start using it from a later date.  Depreciation has to be calculated from the date of capitalization and not acquisition. But still for record purpose date of purchase would be important.  Hence both the dates are maintained.
    Hope this has clarified your doubts.
    Thanks
    GU

  • What is the need  for TMG?

    Hi, iam new to ABAP......

    HI..
    We can use table maintenance for making the creation,deletion,changing the entries easily.
    We can even make use of the validations required for some fields thro' table maintenance,while creating the entry.
    If some fields need to be populated automatically while creating an record in a database,we can make use of table maintenance for this purpose.
    When the extended table maintenance is called, a work area is fetched from the database into an internal buffer for processing on the screen. Either all entries in the database are fetched into the work area, or the selection can be restricted in a view definition or in the calling program.
    Field contents are maintained in an internal buffer, so the database is not automatically accessed after each individual record has been maintaIned. Changes made are only copied from the internal buffer to the database when save is chosen. This buffering gives the maintenance procedure a transaction orientation. This gives you the possibility of discarding changes before the database access (user-controlled "rollback") and allows consistency checks for all changed data, before it is written to the database.
    FOR MORE DETAILS ON TABLE MAINTENANCE VISIT:
    refer.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc
    Re: Table Maintenance Generator
    http://help.sap.com/saphelp_erp2005/helpdata/en/69/c251474ba111d189750000e8322d00/frameset.htm
    <b>Reward points</b>
    Regards

  • What is the need for planning table.

    can anybody explain me about planning table, how and where to use that..

    Dear
    Use of planning table :
    1.Capacity Requirement Planning in Discrete and PP-PI indistutry
    2.For demanad management , you can create PIR and also generate MTS production order based on planned order for those PIR
    3.Decision making on CRP in planning table for operation dispatch , work centre , scheduling , detail scheduling , time , dates of capacity avalution is possible through Planning table under particular overall profile .
    refer : Use of Planning Table (MF50) in Capacity Levelling with Production Order
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PPCRPPPPI/PPCRP_PPPI.pdf
    Regards
    JH

  • What is the need of creating partner functions for sales document type.

    Hi SAP (SD-GURUS),
    Actually we create partner functions  before creating customer ex: sold to party, ship to party, bill to party, and payer.
    These partner functions are going to be copied into sales order while processing sales order.
    Again what is the need of creating partner functions for sales document type.
    Thanks&Regards
    sreenivas peruru

    There are some Partners you could enter at Sales ORder Level. E.g. Sales Person, Employee Responsible, Forwarding Agent, Broker, etc.
    Thus these partner Determination need to be carried out at Sales Order Level & not at Customer Master level.
    So we have to configure partner Determination for various levels e.g. Customer Master, Sales Order, Delivery level etc...
    Hope this helps...
    THanks,
    Jignesh Mehta

  • Illustrator keeps quitting-notice others have had similar issues, not resolved-so what it the reason for "sending a report" to Adobe if nothing can be done with it????? paying for a product that I can't use when I need to use it and no help-come on-someon

    Illustrator keeps quitting…notice others have had similar issues…so what it the reason for "sending a report" to Adobe if nothing can be done with it????? paying for a product that I can't use when I need to use it and no help…come on…someone has to have an answer…HELP Pleeeeease

    <moved from Adobe Creative Cloud to Illustrator>
    reset your preferences -
    acrobat:  http://help.adobe.com/en_US/acrobat/X/pro/using/WS58a04a822e3e50102bd615109794195ff-7feb.w .html
    adobe media encoder: https://forums.adobe.com/thread/1713540
    after effects:  http://helpx.adobe.com/after-effects/using/preferences.html
    dreamweaver:  https://helpx.adobe.com/dreamweaver/kb/restore-preferences-dreamweaver-cs6-cc.html
    flash:  http://helpx.adobe.com/flash/kb/re-create-preferences-flash-professional.html
    illustrator:  http://helpx.adobe.com/illustrator/using/setting-preferences.html
    indesign:  https://forums.adobe.com/thread/526990
    lightroom: https://helpx.adobe.com/lightroom/help/setting-preferences-lightroom.html
    muse (mac): https://forums.adobe.com/thread/1246022?tstart=0
    photoshop:  https://forums.adobe.com/thread/375776
    photoshop elements:  https://helpx.adobe.com/photoshop-elements/kb/preference-file-locations-photoshop-elements .html,  http://www.photokaboom.com/photography/learn/Photoshop_Elements/troubleshooting/1_delete_p references_file.htm
    premiere elements:  https://helpx.adobe.com/photoshop-elements/kb/preference-file-locations-photoshop-elements .html
    premiere pro: http://www.mediacollege.com/adobe/premiere/pro/troubleshooter/trash-preferences.html
    if that fails, uninstall, clean (http://www.adobe.com/support/contact/cscleanertool.html) and reinstall

  • Just bought a new iPod touch 16G - I think it's a 5th gen. - I used my old iPod to record rehearsals.  The new one is stating that my Belken mic is not compatible.  Can I record with this new one?  If so, what do I need for a mic?

    Just bought a new iPod Touch 16G - (I think it's a 5th gen.).   I used my old iPod to record music rehearsals.  This new iPod is stating that my old Belken mic (with new adaptor) is not compatible.  Does this new iPod Touch have ability to record audio?     If so, what do I need for a mic??

    Thanks very much!   I found the app, tested it, and it sounds fairly lifelike.    Big help!!

  • Can someone tell me what settings I need for ipad texting.  Went to Mexico and now can't get the texting to work at all on ipad.  Thanls

    Can someone tell me what settings I need for ipad texting.  I went to Mexico and when I returned the texting does not work on my ipad.  The support at Apple wanted to charge me to get info.
    THanks

    Can't address the problem directly, cause even though my iPad4 is Cell+Wi-Fi, I've never put a SIM in it and never had the need to text, SMS or iMessage, from it. When away from the office or home wireless network, I tether it off the iPhone. Skype, both text and video, work just fine thru the Wi-Fi link, though.
    HOWEVER, when I was hashing out the contract details to get the iPhone 5 about 14 months ago at Telcel, the representative distinctly mentioned that both Visual Voicemail as well as iMessages would be included in the package and they would be mandatory cause "I was getting a (subsidized) Apple iPhone" on a 24 month leash. Then when the gizmo came out of its box for SIM installation and activation, she went thru the motions of making sure both were working properly.  So I assume the carrier has some say in the matter.

  • What permission is needed for a login to access the restored database(backup from different server)

    what permission is needed for a login to access the restored database(backup from different server)
    frequently reach the situation, when vendor restores a database, but he cannot access it unless I remap or add his login to the restored database. What permssion can grant the vendor so that he can but only can access the database he restored, not all other
    databases.

    Hi George,
    According to your description, When you move a database from one server that is running SQL Server to another server that is running SQL Server, a mismatch may occur between the security identification numbers (SIDs) of the logins in the master database
    and the users in the user database. As other post, you can use the sp_change_users_login stored procedure to map SQL Server logins. Also , you can use the following statement after doing the restore database. It will
     fix the mis-mapped SID inside the restored DB.
    ALTER USER <username> WITH LOGIN = <username>
    For more information, you can review the following article.
    http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/do-you-still-use-sp_change_users_login/
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • I need to reinstall lightroom what is the link for 5.5

    What is the link for lightroom 5.5 to download to a new harddrive?

    How to reinstall depends on whether you are using the Cloud-licensed LR which would be available in the CC Desktop apps list, or if you are using the serial-number-licensed LR, which can be downloaded from the Adobe updates page:
    http://www.adobe.com/downloads/updates
    Keep in mind that LR 5.6 was released overnight so LR 5.5 is no longer the newest version.

Maybe you are looking for

  • My Macbook Pro Retina doesn't turn on but charger led works

    I haven't used my mac for a month but it use to work perfectly fine. I tried to use it but it wouldn't turn on. When i plug the magsafe connecter the led goes orange. But when i press the power button it doesn't turn on. i tried smc reset using left

  • PhotoshopCS on Mac crashes while  opening

    Photoshop CS on Mac OS 10.3.9 crashes while opening reading patterns - I beleive a large custom pattern has corrupted but I can't get open to delete. Where do I find on my hard drive to throw out?

  • Need help separating colors in a photo for screen print

    Hey guys, I'm relatively new to Photoshop but I know most of the basics. I have a design here that a band would like to print on a shirt in 2-3 colors: black, grey, and white. Technically I only need the grey and white because it is being printed on

  • ITunes and Norton Internet Securities Fix

    I have had the same problems with iTunes as everybody else.Installed fine but will not open.This was due to NIS blocking iTunes(and many other programs) from accessing the internet.This is what I did with the help from symantec; 1. open nis 2. Select

  • Error in FI posting- J2IUN

    Dear All, In J2IUN simulation is working fine and and when i try to save system showing message ' ERROR IN FI POSTING'. We tried to utilize for the month of May 2009. Is the error beacuse of FI period closed? Please suggest how to overcome this error