首页 > 试题广场 >

下面代码的输出结果 public class ZeroTes

[单选题]
下面代码的输出结果
public class ZeroTest {
    public static void main(String[] args) {
     try{
       int i = 100 / 0;
       System.out.print(i);
      }catch(Exception e){
       System.out.print(1);
       throw new RuntimeException();
      }finally{
       System.out.print(2);
      }
      System.out.print(3);
     }
 }


  • 3
  • 12
  • 123
  • 1
int i = 100/ 0; 有异常,System.out.print(i)不会执行,先执行catch中的System.out.print(1);再执行finally中的System.out.print(2);,实际输出1、2
发表于 2025-05-18 15:46:58 回复(0)

问题信息

难度:
1条回答 38浏览

热门推荐