Java有哪些数据类型?
基本数据类型:
一、数值型
1、整数类型(byte,short,int,long)
2、浮点类型(float、double)
二、字符型 (char)
三、布尔型(boolean)
引用数据类型
1、类(class)
2、接口 (interface)
3、数组
Java中标识符的命名规范?
只能包含数字、字母(大小写,Unicode字符)、下划线 _、美元符$
不能以数字开头
demo1、demo-1、$demo、_demo、1demo
Java的注释有哪几种?请书写一个规范的类文档注释。
文档注释 单行注释 多行注释
/**
* 这个类演示了文档注释
* @author Ayan Amhed
* @version 1.2
* This method returns the square of num.
* This is a multiline description. You can use
* as many lines as you like.
* @param num The value to be squared.
* @return num squared.
*/
举例说明在什么情况下会发生自动类型转换?
int a = 1;
String b = '12';
System.out.println(a+b);
输出的结果为:112
short s1 = 1; s1 = s1 + 1;编译时有什么错?
数据类型不匹配 :s1 是short 类型 ,int不可以转为short型。
String s = "java";String s2 = "java"; boolean flag = (s == s2); 请问 flag 的值是多少,请说明理由。
flag 值是true。s 、s2在内存中的存储地址相等,s == s2, 所以最后的结果为True