"++面试题"
public class _adddeng {
public static void main(String[] args) {
// 面视题
// short s=1;
// s=s+1; //报错 short类型进行数据操作的时候类型自动提升为int 因此short不能等于int
short s = 1;
s += 1; // 正常 隐藏了强制类型转化
// s=(short)(s+1)
}
}
“--面试题 ”
public class _jia_jian {
public static void main(String[] args) {
int a=3;
int b=4;
//int c=a++; //放在后面,先赋值在自增
//int d=b--; //放在后面,先赋值在自减
int c=++a; //放在前面,先自增再赋值
int d=--b; //放在前面,先自减再赋值
System.out.println("a:"+a); //4
System.out.println("b:"+b); //3
System.out.println("c:"+c); //3
System.out.println("d:"+d); //4
//面视题:
int x=4;
int y=(x++)+(++x)+(x*10);
// 4 + 1+(4+1)=6 + 6*10
System.out.println(y);
}
}
java语言中的字符可以存储一个中文字符?
public class CharDemo {
public static void main(String[] args) {
char c='散';
System.out.println(c);
/*
* 面试题:java语言中的字符可以存醋一个中文字符没?
* 答案: 可以,因为java采用的是unicode编码表,一个字符占用两个字节。
*/
}
}
本文由 SAn 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2017/06/20 15:17