zoukankan      html  css  js  c++  java
  • 一组涉及java基础和计组的例题,试试你能答出几个

    1

    int a = 50;
    Integer a1 = 50;
    Integer b1 = 50;
    Integer c1 = 100;
    Integer d1 = a1 + b1;
    a == a1;
    a == b1;
    a1 == b1;
    c1 == a1 + b1;
    c1 == d1;
    

    2.

    int a = 100;
    Integer a1 = 100;
    Integer b1 = 100;
    Integer c1 = 200;
    Integer d1 = a1 + b1;
    a == a1;
    a == b1;
    a1 == b1;
    c1 == a1 + b1;
    c1 == d1;
    

    3.

    int a = 200;
    Integer a1 = 200;
    Integer b1 = 200;
    Integer c1 = 400;
    Integer d1 = a1 + b1;
    a == a1;
    a == b1;
    a1 == b1;
    c1 == a1 + b1;
    c1 == d1;
    

    4.

    double a = 50d;
    Double a1 = 50d;
    Double b1 = 50d;
    Double c1 = 100d;
    Double d1 = a1 + b1;
    a == a1;
    a == b1;
    a1 == b1;
    c1 == a1 + b1;
    c1 == d1;
    

    5.

    double a = 200d;
    Double a1 = 200d;
    Double b1 = 200d;
    Double c1 = 400d;
    Double d1 = a1 + b1;
    a == a1;
    a == b1;
    a1 == b1;
    c1 == a1 + b1;
    c1 == d1;
    

    6.

    double a = 0.1d;
    double b = 0.2d;
    double c = 0.3d;
    c == a + b;
    0.3d == a + b;
    

    7.

    float a = 0.1f;
    float b = 0.2f;
    double c = 0.3f;
    c == a + b;
    0.3f == a + b;
    

    8.

    int a = 0;
    int b = 0;
    a / b;
    

    9.

    double a = 0d;
    double b = 0d;
    a / b;
    

    答案

    ---------t1----------
    true
    true
    true
    true
    true
    ---------t2----------
    true
    true
    true
    true
    false
    ---------t3----------
    true
    true
    false
    true
    false
    ---------t4----------
    true
    true
    false
    true
    false
    ---------t5----------
    true
    true
    false
    true
    false
    ---------t6----------
    false
    false
    ---------t7----------
    true
    true
    ---------t9----------
    NaN
    ---------t8----------
    Exception in thread "main" java.lang.ArithmeticException: / by zero
    
  • 相关阅读:
    洛谷 P3366 【模板】最小生成树
    洛谷 P2820 局域网
    一本通【例4-10】最优布线问题
    洛谷 P1546 最短网络 Agri-Net
    图论模板
    洛谷 AT667 【天下一人力比較】
    刷题记录
    洛谷P1553 数字翻转(升级版)
    tornado硬件管理系统-网络与磁盘的实现(7)
    tornado硬件管理系统-内存与swap的实现(6)
  • 原文地址:https://www.cnblogs.com/INnoVationv2/p/12822632.html
Copyright © 2011-2022 走看看