语言表述还是有问题。。fuck
1.自我介绍
2.项目中遇到哪些问题,怎么解决的
太菜了没答好。。面试官没为难(购票扣减逻辑要复习一下)
3.mq发生了数据积压怎么去解?
面试官感觉我不会,也没为难我
4.Integer=20 Integer=200
5.深拷贝浅拷贝
6.多层内部类深拷贝怎么做(提示socket,序列化反序列化)
import java.io.*;
class Outer implements Serializable {
int outerField;
Inner inner;Outer(int outerField, int innerField) {
this.outerField = outerField;
this.inner = new Inner(innerField);
}// Inner class
class Inner implements Serializable {
int innerField;Inner(int innerField) {
this.innerField = innerField;
}
}// Method to perform deep copy
public Outer deepCopy() throws IOException, ClassNotFoundException {
// Write the object to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(this);// Read the object from the byte array
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bis);
return (Outer) in.readObject();
}
}public class DeepCopyExample {
public static void main(String[] args) {
try {
// Creating an Outer object
Outer original = new Outer(10, 20);
System.out.println("Original object: " + original.outerField + ", " + original.inner.innerField);// Performing deep copy
Outer copied = original.deepCopy();
System.out.println("Copied object: " + copied.outerField + ", " + copied.inner.innerField);
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
}
在这个示例中,Outer类包含一个内部类Inner。通过实现Serializable接口,可以将Outer和Inner类序列化。在deepCopy方法中,通过对象输出流将对象写入字节流,然后通过对象输入流从字节流中读取对象,最终返回深拷贝的对象。
7.subList()用过吗
说没用过,跳过这个问题了,也没为难我,泪目。。。
8.hashset存对象比较是否相等
9.hashcode,equals判断逻辑
10.线程池
11.写一个单例模式(没学。。cao)
public class Singleton {
// 私有静态成员变量,用于保存唯一实例
private static Singleton instance;// 私有构造函数,防止外部通过new关键字实例化对象
private Singleton() {
}// 公有静态方法,用于获取唯一实例
public static Singleton getInstance() {
// 懒汉式单例模式,延迟实例化,只有在需要时才创建实例
if (instance == null) {
instance = new Singleton();
}
return instance;
}// 其他方法...
}
12.算法:定义出链表的数据结构,判断链表是否有环
13.题
环形公路 有4个加油站 ,判断车能否从某个加油站开始绕着环形公路走一圈,如果能,从哪个节点开始能走一圈,要求求出所有的站点。要求时间复杂度O(n),循环一次解决。
每个点加的油为gas【a】gas【b】gas【c】gas【d】
到达某个点耗油为cost【a】cost【b】cost【c】cost【d】
fuck 原来是leetcode上的题
14.数学题四个人(A、B、C、D)晚上过桥,并且只有一个手电筒,每次只能过两个人,并且还需要有一个人回来传递手电_百度知道 (baidu.com)