char tt = '1';
System.out.printf("%c",tt++); 输出是什么?我说的输出时1,面试者告诉我是2.以下垃圾回收的标准时什么?
Object obj = new Object();
Object obj = null;
Object obj = new Object();
obj = new Object();
这个题我当时就说会报错。面试的告诉我这个运行没问题。
其他问题就是不说了。哎
System.out.printf("%c",tt++); 输出是什么?我说的输出时1,面试者告诉我是2.以下垃圾回收的标准时什么?
Object obj = new Object();
Object obj = null;
Object obj = new Object();
obj = new Object();
这个题我当时就说会报错。面试的告诉我这个运行没问题。
其他问题就是不说了。哎
C语言输出不是这样的
如果是 "++tt" 的话 就是 先输出 再 加 那就有可能是1
For the second one, all the instances have the same name. Thus by each new creation, the last one will be crashed. The last row "obj=new Object()" create a valid Instance of Object, because the "obj" has been declared and already created throug "Object obj=new Object()".
估计那HR都跟7楼那样儿~
System.out.printf("%c",tt++);
}}结果是1
这种问题也会是面试题?
char tt = '1';
System.out.printf("%c",tt++);
明明是1。
int test;
public Test() {
test=1;
} public static void main(String[] args) {
char c='1';
System.out.printf("%c",++c);//output is 2
System.out.printf("%c",c++);//output is 1
Test mt=new Test();
System.out.println("now mt 1 is "+mt.toString());//a created object
mt=null; //set the created object as null
mt=new Test();//another object, although with the same name,
//but different memory space
System.out.println("now mt 3 is "+mt.toString());
}
}If somebody is interested, you can run the code by yourself and check the output. The HR-guy may do something wrong with the paper work and forget the basic knowledge as me. Sorry about my reply.
System.out.printf("%c",tt++); ====>1
System.out.printf("%c",++tt); ====>3 Object obj = new Object();
Object obj = null; ==>报错
Object obj = new Object(); ==>报错
obj = new Object();
我觉得面试官是试探LZ的 看看LZ的基础扎实不