2019年 - Java 笔试题汇总

3,050 阅读2分钟

1.下面哪些是Thread类的方法()

A start()
B run()
C exit()
D getPriority()

2.下面关于java.lang.Exception类的说法正确的是()

A继承自Throwable
B实现Serialable接口
C 不可以再被继承
D是抽象类

3.下面程序的运行结果是()

String str1 = "hello";
String str2 = "he" + new String("llo") ;
System.err.println(str1== str2) ;

4.下面程序的运行结果: ()

public static void main(String args[]) {
    Thread t = new Thread() {
        public void run() {
           pong();
        }
    };
    t.run();
    System.out.print("ping");
}
static void pong() {
    System. out.print("pong");
}

A pingpong
B pongping
C pingpong和pongping都有可能
D都不输出

5.下列属于关系型数据库的是()
A Oracle
B MySQL
C Redis
D MongoDB

6.下列不可作为JAVA语言的修饰符的是() A al
B $1
C _1
D 11

7.指出下列程序运行的结果()

public class Example {
String str = new String ("good");
char[]ch={'a''b''C'};
public static void main(String args[] ) {
    Example ex = new Example();
    ex. change (ex.str,ex.ch);
    System. out.print(ex.str +" and");
    System. out.print(ex.ch) ;
public void change (String str, char ch[]) {
    str = "test ok";
    ch[0] = 'g' ;
}

A good and abc
B good and gbc
C test ok and abc
D test ok and gbc

8.0.6332的数据类型是()
A float
B double
C Float
D Double

9.下面哪个流类属于面向字符的输入流()
A BufferedWriter
B FileInputStream
C ObjectInputStream
D InputStreamReader

10.Java接口的修饰符可以为()
A private
B protected
C public
D abstract

11.如果已经定义了显式的构造函数,可以通过默认构造函数能创建对象吗()
A是
B否

12.新建一个流对象,下面哪个选项的代码是错误的? ( )
A new BufferedWriter(new FileWriter("a.txt")); B new BufferedReader(new FileInputStream("a.dat")); C new GZIPOutputStream(new FileOutputStream("a.zip")); D new ObjectInputStream(new FileInputStream("a.dat");

13.下面程序能正常运行吗

public class NULL {
    public static void haha() {
        System.out.println("haha");
    }

    public static void main(String[] args) {
        ((NULL) null).haha();
    }
}

A不能 B能

答案:能,运行后的结果为 haha

15.HTTP请求有几种,请说一说他们的区别和应用场景

16.请简述struts1的工作流程

17.用一条SQL语句查询出每门课都大于80分的学生姓名

name kecheng fenshu
张三 语文 81
张三 数学 75
李四 语文 76
李四 数学 90
王五 语文 81
王五 数学 100
王五 英语 90
SELECT NAME 
FROM
	( SELECT NAME, min( fenshu ) 
	FROM score 
	GROUP BY NAME 
	HAVING min( fenshu ) > 80 ) stu

18.什么是主键?什么是外键?

19:左连接怎么写,和右连接有什么区别。

20.甲乙丙丁戊5个人中,有两个人是从不说谎的老实人,另外3位是总是说谎的骗子。下面是他们所说的话:
甲:乙是骗子
乙:丙是骗子
丙:戊是骗子
丁:甲和乙都是骗子
戊:甲和丁都是老实人
问谁是老实人?

答案:甲丙