【IGT】 Paper Test For Campus Recruiting
注:分享出来,仅做个人知识点的查漏补缺以及鞭策自己更加努力地学习!(粗体红字为鄙人做的答案,可能会有错误,还望能有人指出。)
Part 1:
1、which of these is a legal definition of a method named m assuming it throws IOExecption,and returns void .Also assume that the method does not take any arguments.Select the one correct answer.
A void m() throws IOExecption{}
B void m() throw IOExecption{}
C void m(void) throw IOExecption{}
D void m(){}throws IOExecption{}
2、which of the following is legal identifier name in java.
A %abcd
B 1abcd(第一个为数字1)
C package
D _a_long_name
(知识点说明:Java语言规定标识符是以字母、下划线"_"或美元符号"$"开始,随后可跟数字、字母、下划线或美元符号的字符序列,当然不能用关键字作为标识符。)
3、what will happen when you attempt to compile and run the following code?
package igt;
public class igt {
public static void main(String[] args){
int i;
switch(i){
case 0:System.out.println(0);
case 1:System.out.println(1);break;
case 2:System.out.println(2);
case 3:System.out.println(3);break;
}
}
}
A 0
B 01
C 0123
D compile error
(知识点说明:关于java变量是否自动初始化问题--成员变量会被初始化,局部变量不会初始化。局部变量如果定义时没有进行初始化,系统不会自动为其进行初始化,因而编译时会出错。如下图所示:
4、what will be the output of the program?
public class test_4 {
static class A{
public int x = 10;
public int y = 20;
int f(){
return y;
}
}
static class B extends A{
public int x = 1;
public int y = 30;
int f(){
return y;
}
}
public static void main(String[] args){
A a = new B();
System.out.print(a.x+",");
System.out.println(a.f());
}
}
A 10,20
B 10,30
C 1,20
D 1,30
(实验得出结果是B,不解中....)
5、what will be the output of the program?
public class test_5 extends Base{
static{
System.out.print("6");
}{
System.out.print("5");
}
public test_5(){
System.out.print("4");
}
public static void main(String[] args){
new test_5();
}
}
class Base{
static{
System.out.print("3");
}{
System.out.print("2");
}
public Base(){
System.out.print("1");
}
}
A 326514
B 361425
C 362154
D 362514
(实验得出结果是C,不解中....)
Part 2:
6、please decribe the scenarios of using String StringBuffer StringBuilder,and what is the difference between StringBuffer and StringBuilder?
7、please explain the difference between checked exception and runtime exception and the usage of these two kinds of exception.
8、please give an example of self-defined class that could be sorted in Collections.sort() method
9、please list at least three design patterns and its usage in your daily development.
Part 3:
10、please implement a function to find the longest common sub-string of two given string.
for example:
string a: abcdefg12345
string b:cdef234
longest common sub-string:cdef
(字符串匹配问题常考查,需研究透彻!)
--------------------------未解问题,待续。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。