Everything sux

Wednesday, August 31, 2005

[Java] Conosci Davvero Java?

Java è un linguaggio complicato.
Avendo un sacco di colleghi in disaccordo con questa tesi, mi sono preparato una piccola lista di domande per dimostrare che nemmeno loro si immaginano quanto sia complicato ;)

Se vi ritenete esperti Java dovreste sapere le risposte, se non le sapete, sono tra i commenti



  1. Riscaldamento: cosa stampa questo codice?

    public class Main {
    int myInt;
    double myDouble;
    boolean myBoolean;

    public static void main( String []args){
    Main obj=new Main();
    System.out.print(obj.myInt);
    System.out.print(" " + obj.myDouble);
    System.out.println(
    " " + obj.myBoolean);
    }
    }


  2. Dato il codice

    Calendar cal = Calendar.getInstance();
    cal.set(1999, 12, 31);
    System.out.print(cal.get(Calendar.YEAR) + " ");
    System.out.print(cal.get(Calendar.MONTH) + " ");
    System.out.println(cal.get(Calendar.DAY_OF_MONTH));

    cosa credete che venga stampato a schermo?

  3. In questo codice c'è un evidente errore, siete in grado di individuarlo?

    void copy(File src, File dst) throws IOException {
    FileChannel in = null, out = null;
    try {
    in = new FileInputStream(src).getChannel();
    out = new FileOutputStream(dst).getChannel();
    long size = in.size();
    MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
    out.write(buf);
    } finally {
    if (in != null) in.close();
    if (out != null) out.close();
    }
    }



  4. Quanto vale
     1 << 32


  5. Eseguendo questo codice:

    public static void main(String[] args) {
    System.out.println(10/magic(-2147483648));
    }
    static int magic(int x){
    if (x !=0)
    return x+x;
    return 1;
    }

    cosa viene stampato a schermo?


  6. I modifier sono quelle cose tipo public o static. Facile, direte voi. La domanda è: quanti modifier ci sono in java?


  7. Se per qualche assurda ragione avete azzeccato la risposta precedente, sareste in grado di riee quali e spiegare a cosa servono?


  8. Avendo cura di includere java.lang.reflect.*, Cosa stampa questo spezzone:
    System.out.print( Modifier.toString( Member.class.getModifiers() ) );
    ?


  9. Qual'è l'errore in questa innocua classe?

    public class Main {


    public static final double twoPI
    = 2 * myPI;
    public static final double myPI
    = Math.PI;
    }


  10. Potrebbero sembrare banali, ma io mi sbaglio spesso.. Quali tra queste sono assegnazioni valide ?
  • double b = 1.0;
  • float c = .1f;
  • float a = 0.1;
  • float d = 1.f ;
  • float e = 3.2f ;
  • double f = 1. ;
  • float g = 0x23595959L ;
  • float h = 0x595959F ;
  • double i = 0X0;
  • int l = 2147483648;
  • double m = 2036373547;
  • float n = 2147483648;
  • double m = 2147483648


35 Comments:

  • 1: 0 0.0 false. Basta ricordare che le variabili hanno dei valori di default in java.

    2: 2000 1 31. I mesi si contano da zero, per retrocompatibilità con le api deprecate di Date

    3: se viene lanciata un'eccezione da in.close() c'è un resource leak

    4: vale 1

    5: non viene stampato nulla, viene lanciata un'eccezione DiviosionByZero, un problema relativo al fatto che i tipi numerici in java non sono effettivamente astratti come in Ruby/Python/Smalltalk/Lisp, ma sono degli spaziucci di memoria

    6: 11 (!!)

    7: public, private, protected, static, native, volatile, abstract,
    synchronized, strictfp, final, transient. Per le spiegazioni prendete le spec di java :)

    8: "public abstract interface". Se adesso state pensando che una interfaccia stratta sia qualcosa di magico, ricredetevi, tutte le interfacce sono abstract solo che non si sa perché questa cosa viene fuori solo tramite reflection.

    9: javac non è abbastana intelligente da capire che potrebbe leggere la dichiarazione di costante che avviene dopo l'uso (è più intelligente in altri casi)

    10: ultimo, penultimo e quart'ultimo. La cosa affascinante è che 2147483648 non è un int valido, mentre -2147483648 lo è.

    By Blogger verbat, at August 31, 2005 10:03 AM  

  • trovo + significativi i test di Javabackbelt.com.

    Hai vouluto dimostrare che ci sono delle cosette sporche in java? ci sono in tutti i linguaggi, in tutti i framework e mi sento di dire in tutte le soluzioni tecnologiche.

    per la domanda 7 esiste anche il fatto di non mettere nulla come modifier, il compilatore lo consente e salta fuori una specie di protected...

    By Blogger ::SammyRulez::, at August 31, 2005 11:37 PM  

  • quoto il messaggio precedente e aggiungo: lo stupore su certe risposte piuttosto palesi denotano una scarsa conoscenza del linguaggio. Prima di fare il professore datti allo studio.
    gigi

    By Anonymous Anonymous, at September 1, 2005 2:27 AM  

  • Se sono queste le ragioni a sostegno della complessita' di Java, allora viene dimostrato solo il contrario.
    L'unico punto a favore e' la domanda 7, e non basta proprio a fare di Java un linguaggio complesso.

    By Anonymous Anonymous, at September 1, 2005 3:57 AM  

  • Sono d'accordo che ci sono delle cosette sporche in qualsiasi ambienti (sebbene in certi più che in altri)

    E' ovvio che alcuni risposte fossero palesi, volete un giochino un cui non si azzecca nemmeno una risposta?
    Se vuoi ci metto poco, ma parlare di generic ed enum, di varianza, di f bounded polimorphism etc.. quello sarebbe fare davvero il professore, secondo me.

    By Blogger verbat, at September 1, 2005 4:02 AM  

  • This comment has been removed by a blog administrator.

    By Blogger Free Site Submit, at September 1, 2005 4:42 AM  

  • This comment has been removed by a blog administrator.

    By Anonymous Anonymous, at September 1, 2005 4:48 AM  

  • Potresti motivare la risposta 10, compreso il sarcasmo riguarda la 'cosa affascinante'?

    By Anonymous Giuseppe M, at September 2, 2005 3:09 AM  

  • siccome un int ha solo 32 bit di precisione, può rappresentare solamente 4294967296 numeri. Siccome uno di questi è lo zero, i numeri non-zero rappresentabili sono "asimettrici" rispetto a questo.

    Lo trovo affascinante perché sono abituato a pensare che due numeri con un meno davanti sono in un certo senso la stessa cosa. Posso in ogni caso dire che x è la stessa cosa che (-(-x)).
    Tra l'altro se non ricordo male lo standard C recente si comportà così, rifiutando sia 2147483648 che -2147483648 come int.

    By Blogger verbat, at September 2, 2005 8:46 AM  

  • Among these magnificent benefits is the chance to be able to promote your business, any business,

    By Anonymous Anonymous, at November 4, 2005 12:40 AM  

  • Quello che realmente stupisce è il numero di individui che non sono disposti ad ammettere le enormi, spaventose, terrificanti magagne di java.
    D'altro canto fin dai tempi delle diatribe C64 vs Spectrum c'erano sedicenti programmatori disposti a giurare sulla assoluta superiorità del BASIC rispetto all'assembly.

    By Anonymous Anonymous, at November 18, 2005 10:01 PM  

  • Hi verb! Thanks for the great information on [Java] Conosci Davvero Java?.

    If you have time check out my list page. It is a huge list of thousands of different and interesting things for sale online!

    By Anonymous catalog, at December 22, 2005 7:09 PM  

  • Hi verb! Thanks for the great information on [Java] Conosci Davvero Java?.

    If you have time check out my clickbank page. It is a huge list of thousands of different and interesting things for sale online!

    By Anonymous clickbank, at December 23, 2005 12:03 AM  

  • I read over your blog, and i found it inquisitive, you may find My Blog interesting. My blog is just about my day to day life, as a park ranger. So please Click Here To Read My Blog

    By Blogger darrelhill3016, at December 31, 2005 11:31 AM  

  • Hi,
    I was searching through Blogger to see if I can find some information on Business Opportunity. I stumbled on your blog, as this was not quite what I was looking for about Business Opportunity. I did however read your blog and found it quite interesting, keep up the good work and hopefully I will visit it again.
    Regards,

    By Anonymous Making Money, at January 3, 2006 3:20 AM  

  • I read over your blog, and i found it inquisitive, you may find My Blog interesting. So please Click Here To Read My Blog

    http://pennystockinvestment.blogspot.com

    By Blogger eddymartin04248733, at January 22, 2006 12:32 AM  

  • Get any Desired College Degree, In less then 2 weeks.

    Call this number now 24 hours a day 7 days a week (413) 208-3069

    Get these Degrees NOW!!!

    "BA", "BSc", "MA", "MSc", "MBA", "PHD",

    Get everything within 2 weeks.
    100% verifiable, this is a real deal

    Act now you owe it to your future.

    (413) 208-3069 call now 24 hours a day, 7 days a week.

    By Blogger howardandres10759758, at May 6, 2006 5:57 AM  

  • hey, I just got a free $500.00 Gift Card. you can redeem yours at Abercrombie & Fitch All you have to do to get yours is Click Here to get a $500 free gift card for your backtoschool wardrobe

    By Blogger lkyx0svv99wdvb, at October 8, 2006 12:44 PM  

  • hey, I just got a free $500.00 Gift Card. you can redeem yours at Abercrombie & Fitch All you have to do to get yours is Click Here to get a $500 free gift card for your backtoschool wardrobe

    By Blogger gkaf3hzlk09awhu, at October 10, 2006 7:22 AM  

  • Well, thish-yer Smiley had rat-tarriers, and chicken cocks, andtom-cats and all online brueste arschfick of them kind of things, till you couldn't rest, andyou couldn't fetch nothing for him to bet on but he'd match you.The Anecdotes andReminiscences was completed, but publishers had not jumped at thecollected gems of fette titten kostenlos Alabama sense and wit.No onecould have detected his disappointment in his manner, nacktbilder exfreundinnen albeit hissentences were short and incomplete.Through my fault a girl erotik messe tried to protectherself from the consequences of a liaison with me by securing anabortion.

    By Blogger sink sink socks, at January 2, 2007 11:14 PM  

  • Hi all!
    New Game
    http://italiagame.org

    Bye

    By Anonymous Anonymous, at January 21, 2007 2:29 AM  

  • http://italiagame.org/site

    By Anonymous Anonymous, at January 30, 2007 7:08 PM  

  • finance idustrial all fico score.
    bugiallis.
    chasecreditcard.
    chase credit card.
    refinance mortgage loan.
    [url=http://refinance-mortgage-loan.110mb.com][/url]

    By Anonymous Anonymous, at January 31, 2007 3:47 AM  

  • Buon giorno.
    quella era una cosa piacevole, e potete aiutarli che cerco
    http://probabile-formazione-calcio-serie.corsi-di-formazione.org probabile formazione calcio serie

    Quello e tutto.

    By Anonymous Anonymous, at February 26, 2007 10:20 AM  

  • Have you tried Phentramine or Hoodia Diet Pills? They have a good selection here Hoodia Weightloss Pills

    By Blogger No Hassle Loans, at March 11, 2007 3:26 PM  

  • Regretting any inconvenience that thistransaction may cause you, I am,Yours medical gyno fetish respectfully,EDWARD EASTMAN ELLSWORTH.On the contrary, there will be atendency in the primary apparatus to abandon the painful memory pictureas soon as it is in any way awakened, as the sex live fotos overflow of its excitementwould surely produce (more precisely, begin to produce) pain.But from the moment that the suppressed thoughts are powerfully occupiedby the unconscious wish-feeling and abandoned by the foreconsciousoccupation, they succumb to the primary psychic process and strive onlyfor motor discharge; or, if the path be free, russian teen pussy for hallucinatory revivalof the desired perception identity.Should he give away his brilliant inside information,drawn from the Hints and Helps book, and be cowgirls rivalled in the glory ofhis manners and bearing? Why should he not pass on alone, perfectlycomposed, and reap the field of glory unsupported? His knees gave wayand he sat down without intending it.

    By Blogger sink sink socks, at March 20, 2007 1:18 AM  

  • After having discussed his repast, and washed it down with a bottle ofchoice old claret, he resolved upon a visit to japa porno Long Island to view hispurchase.The analysis of obscure andintricate dreams discloses something india sex bilder very similar; the dream scene againpictures as realized some desire which regularly proceeds from the dreamideas, but the picture is unrecognizable, and is only cleared up in theanalysis.Jacobus say, to enter in seitensprung sex no man's pry -vacy; but I do want to know who it may be, like, that I hev inmy house.Gideon bowed to right and toleft, low, grinning, assured comedy obeisances; but gratis kontakt as the laughterand applause grew he shook his head, and signaled quietly for thedrop.

    By Blogger sink sink socks, at March 26, 2007 12:46 AM  

  • But on the firstappearance of my double--whom I sent on this fatal Monday to the www fifthmeeting--he was the sixty-seventh man who entered the room.Chillcross-draughts whistled in from cracks too numerous to be stopped up,and the miserable Van Kamps could only cough and shiver, and envy theTutts and the www driver, non-combatants who had been fed two hoursbefore.Forgetting everything except hischerished ambition, he braced himself for the contest, took a twisthold on the lines, sent a sharp, quick call to his horse, and let himout for all that was in him www.Leonard is one of www the kindest, most generous, and most benevolent ofwomen--she does good in every possible way.

    By Blogger sink sink socks, at March 28, 2007 12:15 AM  

  • flower shops in billings mt transcona florist
    flower girl dress pattern big old tucci flower tucci florist in auburn alabama flowers in the dirt album
    how to make royal icing flowers

    By Anonymous Anonymous, at September 23, 2010 5:11 PM  

  • Androxan hingegen wirkt nachhaltig und und ohne die Cialis Soft Tabs fur unterwegs geeignet. Sie notwendige und medizinisch richtige Potenzmittel wie unangenehm und peinlich andere Krankheiten verursacht. Ausland In unserer zertifizierten Apotheke erhalten Sie rezeptfrei original Cialis, Cialis wirken deutlich schneller als Potenzpillen wie bestimmte.
    [URL=http://buy-tadalafil-cialis-online.info/kaufen-cialis-in-deutschland-rezeptfrei-.html]Kaufen cialis in deutschland rezeptfrei [/URL]

    By Anonymous Anonymous, at September 25, 2010 3:55 PM  

  • black cat music cd c c music factory midi
    ta-da lil mo music video istock music sheet music for alkaline trio churchtown school of music
    timeline of music devices

    By Anonymous Anonymous, at October 1, 2010 5:00 PM  

  • shreveport country music sharpies music from the movie troy
    lounge lizard royalty free music the music artist bimbo william betz ohio university music gutar tab music donlodes
    zelda's lullaby sheet music

    By Anonymous Anonymous, at October 3, 2010 12:03 AM  

  • http://ariadnerestaurant.com/diss/index.html free printable disney coloring pages disney world golden age club

    By Anonymous Anonymous, at October 6, 2010 8:04 AM  

  • What is does accutane cause blindness or accutane gallstones and accutane theraputic?
    You can Buy Accutane Online in canada and usa cheap now.
    A accutane lawsuits.

    By Anonymous Anonymous, at October 20, 2010 9:28 AM  

  • текст песни
    [url=http://remuz.ru/407-юрий-антонов.html]слушать юрий антонов[/url]
    бесплатная музыка
    [url=http://remuz.ru/345-noize-mc.html]mp3 noize mc[/url]

    By Anonymous Anonymous, at November 30, 2010 11:19 PM  

Post a Comment

<< Home