一组涉及java基础和计组的例题,试试你能答出几个

Posted innovationv2

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一组涉及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

以上是关于一组涉及java基础和计组的例题,试试你能答出几个的主要内容,如果未能解决你的问题,请参考以下文章

10个Linux脚本面试题,看看你能答出几个?

Android 进阶延伸技术点,你能答出几个?

唯品会Java面试时问到的10道问题,你能答出几道?

面试题系列|Javaspring boot 11问,你能答出几问?

五面阿里技术专家岗,已拿offer,这些面试题你能答出多少

这八十一道java高级框架面试题你能答出多少题?