写在最后
为了这次面试,也收集了很多的面试题!
以下是部分面试题截图
import java.util.List;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.filechooser.FileView;
public class Tankclient extends Frame {
public static final int GAME_WIDTH = 800;//定义新的常量
public static final int GAME_HEIGHT = 600;
Tank myTank = new Tank(50, 50, true, Tank.Direction.STOP, this);//定义Tank
Wall w1 = new Wall(100, 200, 20, 150, this), w2 = new Wall(300, 100, 300, 20, this);
List<Explode> explodes = new ArrayList<Explode>();
List<Missile> missiles = new ArrayList<Missile>();//利用容器加多发子弹
List<Tank> tanks = new ArrayList<Tank>();
Image offScreenImage = null;//定义屏幕背后背景图片
Blood b = new Blood();
private File file;
public void paint(Graphics g) { //重写paint方法
Object bg = null;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage("data\\bg.jpeg");
g.drawImage(image, 0, 0, null);//背景图片
g.drawString("missiles count:" + missiles.size(), 10, 50);
g.drawString("explodes count:" + explodes.size(), 10, 70);
g.drawString("tanks count:" + tanks.size(), 10, 90);
g.drawString("tanks life:" + myTank.getLife(), 10, 110);
if (tanks.size() <= 0) {
for (int i = 0; i < 5; i++) {
tanks.add(new Tank(50 + 40 * (i + 1), 50, false, Tank.Direction.D, this));
}
}
for (int i = 0; i < missiles.size(); i++) {
Missile m = missiles.get(i);
m.hitTanks(tanks);
m.hitTank(myTank);
m.hitWall(w1);
m.hitWall(w2);
m.draw(g);
//if(!m.isLive()) missiles.remove(m);//出界后去除这个子弹
//else m.draw(g);
}
for (int i = 0; i < explodes.size(); i++) {
Explode e = explodes.get(i);
e.draw(g);
}
for (int i = 0; i < tanks.size(); i++) {
Tank t = tanks.get(i);
t.collidesWithWall(w1);
t.collidesWithWall(w2);
t.collidesWithTanks(tanks);
t.draw(g);
}
myTank.draw(g);
myTank.eat(b);
w1.draw(g);
w2.draw(g);
b.draw(g);
}
public void update(Graphics g) {//调用update方法
if (offScreenImage == null) {
offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT);//创建creatImage
}
Graphics gOffScreen = offScreenImage.getGraphics();
Color c = gOffScreen.getColor();
gOffScreen.setColor(Color.GREEN);//新的颜色
gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);//用背景颜色画一个方块
gOffScreen.setColor(c);//设回原来的颜色
paint(gOffScreen);//调用paint方法
g.drawImage(offScreenImage, 0, 0, null);//图片一次性画到前面
}
public void lauchFrame() {
for (int i = 0; i < 10; i++) {
tanks.add(new Tank(50 + 40 * (i + 1), 50, false, Tank.Direction.D, this));
}
this.setLocation(400, 300);//左上角点出现的位置
this.setSize(GAME_WIDTH, GAME_HEIGHT);//宽800高600
this.setTitle("TankWar");//设置标题
this.addWindowListener(new WindowAdapter() { //匿名类监听类
public void windowClosing(WindowEvent e) { //重写父类
System.exit(0); //正常退出
}
});
this.setResizable(false);//不改变窗口大小
this.setBackground(Color.GREEN);//设置背景色
this.addKeyListener(new KeyMonitor());//键盘监听器
setVisible(true);
new Thread(new PaintThread()).start();//启动线程
new Thread(new Runnable() {
@Override
public void run() {
new Music().playmusic();
}
}).start();
}
public static void main(String[] args) {
Tankclient tc = new Tankclient();
tc.lauchFrame();
}
private class PaintThread implements Runnable { //内部类
public void run() {
while (true) {//不停顿循环
repaint();//调用外部包装类
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
private class KeyMonitor extends KeyAdapter { //键盘监听器类 键盘按下键
public void keyReleased(KeyEvent e) { //键盘抬起来的键
myTank.keyReleased(e);
}
public void keyPressed(KeyEvent e) {
myTank.keyPressed(e);
}
}
}
**Music**
import javax.sound.sampled.*;
import java.applet.*;
import javax.swing.JFrame;
import java.io.File;
import java.net.URL;
import java.net.URI;
public class Music extends JFrame { // 此处Music类继承GameWindow
File f;
URL url;
URI uri;
Music() {
try {
f = new File("data\\坦克大战-战斗5.wav");
uri = f.toURI();
总结
我个人认为,如果你想靠着背面试题来获得心仪的offer,用癞蛤蟆想吃天鹅肉形容完全不过分。想必大家能感受到面试越来越难,想找到心仪的工作也是越来越难,高薪工作羡慕不来,却又对自己目前的薪资不太满意,工作几年甚至连一个应届生的薪资都比不上,终究是错付了,错付了自己没有去提升技术。
这些面试题分享给大家的目的,其实是希望大家通过大厂面试题分析自己的技术栈,给自己梳理一个更加明确的学习方向,当你准备好去面试大厂,你心里有底,大概知道面试官会问多广,多深,避免面试的时候一问三不知。
大家可以把Java基础,JVM,并发编程,MySQL,Redis,Spring,Spring cloud等等做一个知识总结以及延伸,再去进行操作,不然光记是学不会的,这里我也提供一些脑图分享给大家:
希望你看完这篇文章后,不要犹豫,抓紧学习,复习知识,准备在明年的金三银四拿到心仪的offer,加油,打工人!
[外链图片转存中…(img-jdltJt3y-1715106997152)]
[外链图片转存中…(img-uDKCjXYW-1715106997153)]
希望你看完这篇文章后,不要犹豫,抓紧学习,复习知识,准备在明年的金三银四拿到心仪的offer,加油,打工人!