文档介绍:公司笔试面试题分析
本套题目重要出自神州数码,华为,笔试考试题以及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];
: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
将会得到什么成果?
A. 将会顺利通过编译,。
B. 编译时在//3处出错。
C. 编译时在//2处出错。
D. 编译时在//1处出错。
关于下述程序:C
public class Divide
{
public static void main(String args[])
{
("" = ""+); //1
(""17/0 = ""+17/0); //2
}
}
描述对的是?
A. 编译出错
B. 编译通过,运营时//1、//2处均浮现异常
C. 编译通过,运营时//1处得到一种无穷大值,//2处将浮现异常
D. 编译通过,运营时//1处浮现异常,//2处将得到一种无穷大值
有下面程序:B
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”);
(str1==str2);
(str3==str4);
}
}
输出成果是?
A true true B true false C false true D false false
关于下面类描述中对的是:C
class Test {
void test(int i) {
(""I am an int."");
}
void test(String s) {
(""I am a string."");
}
public static void main(String args[]) {
Test t=new Test();
char ch='y';
(ch);
}
}
A. 编译出错
B. 编译通过,运营出错
C. 编译通过,运营时输出“I am an int”
D. 编译通过,运营时输出“I am a string”
如但愿父类中某成员变量能被任何包中子类直接访问,那么定义该变量时使用限定