本套题目出自中关村知名软件公司笔试考试题以及SCJP认证考题
一, 选择题
下列数组初始化正确的是:C
A int[5] a= {1,2,3,4,5};
B int[2][2] a = {{1,2},{3,4}};
C int[][] a = {{2,3,4,5},new int[3]};
D int[][] a = new int[][5];
下面的程序名为Studentjava:B
――》构造器重载,可以多样化的创建对象, 构造器是用来创建对象的
public class Student
{
private String name;
public Student(String s_name) //1
{
name = s_name; //2
}
public static void main(String args[])
{
Student s = new Student(); //3
}
}
使用如下指令编译:
javac Studentjava
将会得到什么结果?
A 将会顺利通过编译,并将产生一个Studentclass的类文件。
B 编译时在//3处出错。
C 编译时在//2处出错。
D 编译时在//1处出错。
关于下述程序:C
――》运行时才会报错
public class Divide
{
public static void main(String args[])
{
Systemoutprintln("170/0 = "+170/0); //1
Systemoutprintln("17/0 = "+17/0); //2
}
}
描述正确的是?
A 编译出错
B 编译通过,运行时//1、//2处均出现异常
C 编译通过,运行时//1处得到一个无穷大值,//2处将出现异常
D 编译通过,运行时//1处出现异常,//2处将得到一个无穷大值
有下面程序:B
――》3,4两个对象,前面的是地址的引用,先创建“ABC”一个串对象,再将ABC的副本COPY给一个NEW的对象,原来的ABC被垃圾回收器回收了。不放在池子里。
――》1,2 是放到池子里的,内存里有一个所谓的池子,创建时要先查池子,池子里有,就拿池里子有的,如果没有新创建一个。
这个池子,只有String有,别的类没有,因为它的使用是率最高的。
public class TestString
{
public static void main(String[] args)
{
String str1 = “abcd”;
String str2 = “abcd”;
String str3 = new String(“abcd”);
String str4 = new String(“abcd”);
Systemoutprintln(str1==str2);
Systemoutprintln(str3==str4);
}
}
输出结果是?
A true true B true false C false true D false false
关于下面的类描述中正确的是:C
--》方法的重载,名相同,参数个数和类型不同,
――》方法可以和构造器重名,
――》char和INT,STRING,无任何关系统,CHAR在内存中就是INT类型,键盘上可看见的都有一个整数和他对应,一个字符可存汉字,
class Test {
void test(int i) {
Systemoutprintln("I am an int");
}
void test(String s) {
Systemoutprintln("I am a string");
}
public static void main(String args[]) {
Test t=new Test();
char
中关村面试题(Java部分) 来自淘豆网m.daumloan.com转载请标明出处.