三七互娱18秋招题分享!第一次发帖

我的第一个帖子😃有点激动  发表一下去年秋招时三七互娱java开发的试题,有需要的同学可以看一下
1、请写出下面代码的方法打印出来的内容。

public class StringTest {

public static void main(String args[]) {

String a = "this is String a";

String b = a;

a = "this is String b";

System.out.println(b);

}

}

2、请分别写出printOne()方法和printTwo()方法的输出

public class PrintTest {

private String a;

public void printOne(){

System.out.println(a+"One");

}

public void printTwo(){

String b;

System.out.println(b+"Two");

}

}

3、请写出下面代码的输出结果

public class Test{

public static void main(String[] args){

SubBean subBean = new SubBean();

System.out.println(subBean.id);

}

}

class Bean{

public static int id = 0;

}

public class SubBean extends Bean{

public int id = 1;

}

4、请补全代码,让下面的方法输出字符串”a:1 , b:2”

public class PrintTest {

public static void main(String[] args){

System.out.println(new Bean(1, 2));

}

}

class Bean{

private int a;

private int b;

public Bean(int a, int b){

this.a = a;

this.b = b;

}

}

5、请写出下述代码的输出内容

public class Equals {

public static void add3(Integer i){

int val = i.intValue();

val +=3;

i = new Integer(val);

}

public static void main(String args[]){

Integer i = new Integer(0);

add3(i);

System.out.println(i.intValue());

}

}

6、请补全以下代码,让单件PlayerManagergetInstance()方法成为线程安全的,并且满足以下条件。

A: 使用懒加载模式初始化该单件

B: 多个线程访问该方法,可以获取到同一个对象实例

C:当对象实例以及被创建以后,如果可以的话,不再需要同步机制

public class PlayerManager{

public static PlayerManager getInstance(){

//这里返回该对象的唯一实例

}

}

}

7、请补全代码,让下面的断言可以成立

public class Test2{

public static void main(String[] args){

Map<Key, String>map = new HashMap<Key , String>();

map.put(new Key(1), "result 1");

map.put(new Key(3), "result 2");

map.put(new Key(3), "result 3");

map.put(new Key(4), "result 4");

map.put(new Key(5), "result 5");

map.put(new Key(6), "result 6");

assert map.size() == 2;

assert map.get(new Key(1)).equals("result 5");

assert map.get(new Key(4)).equals("result 6");

}

}

class Key{

private int id;

public Key(int id){

this.id = id;

}

}

8、假设有一栋13层的大楼,如果我们从大楼中的某一层向下扔一颗玻璃珠,玻璃珠就会摔碎,请问,要找出刚刚好可以摔碎玻璃珠的那一层,我们需要几颗玻璃珠,为什么?

9、请写出下面的方法打印出来的内容

public class Test{

public static String output="";

public static void foo(int i){

try{

if(i==1){

throw new Exception();

}

output += "1";

} catch(Exception e) {

output += "2";

return;

} finally {

output += "3";

}

output += "4";

}

public static void main (String args[]){

foo(0);

foo(1);

System.out.println(output);

}

}

请设计一个排序算法,并把思路写下来,该排序算法有下列限制。

A: 我们需要对一个4g的文件进行排序,这个文件中全是以二进制方式存储的数值,数组类型是整形。

B: 我们执行排序算法的机器只有2g的内存,也就是说,不可以一次将该数据全部读取到内存中进行排序。

#秋招##三七互娱##笔试题目##Java工程师#
全部评论

相关推荐

3 18 评论
分享
牛客网
牛客企业服务