🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17264

quiz

#17264
From: Edoardo Comar
Date: Mon, 23 Nov 1998 00:00
39 lines
1213 bytes
Without minding  about bad programming style,
will this program output 1010 or -10 on (*) ?

package edo.syntaxTest;

public class FinallyTest
{

  public static void main(String[] args)
  {
    FinallyTest finallyTest = new FinallyTest();

    System.out.println(finallyTest.test(0));
    System.out.println(finallyTest.test(10)); // (*)
  }

  public int test(int param)
  {
    int _result = 1000;
    try
    {
      if(param <= 0)
        throw new IllegalArgumentException("param invalid");

      return _result += param;
    }
    catch(Exception exc)
    {
       System.out.println("catch!");
       _result  = -20;
    }
    finally
    {
       System.out.println("finally!");
       _result  = -10;
    }
    return _result;
  }
}
Technical Details
Message-ID: <73b97j$5q012@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,f51b0f21d8f8b176,start
X-Google-Attributes: gidf74b3,public
From: "Edoardo Comar" <comar@tecnest.it>
Subject: quiz
Date: 1998/11/23
Message-ID: <73b97j$5q012@forums.borland.com>
X-Deja-AN: 414738602
Organization: Another Netscape Collabra Server User
X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.language