小小又去面试了,今日面试总结如下
第一题
数据库有a如下的表,表结构如下
员工编号 | 职务 | 组织编码 |
---|---|---|
employeeID | JobTitle | OrganizationCode |
要求,编写部门员工数>10人的员工
编写相应的SQL语句
回答
select * from a group by OrganizationCode having count(employeeID) > 10;
第二题
在如下的源代码文件中,那个是正确的类定义
A
public class test {
public int x = 0;
public test(int x){
this.x = x;
}
}
B
public class Test{
public int x = 0;
public Test(int x){
this.x = x;
}
}
C
public class Test extends T1, T2 {
public int x = 0;
public Test(int x){
this.x = x;
}
}
D
public class Test extends T1 {
public int x = 0;
public Test(int x){
this.x = x;
}
}
E
protected class Test extends T2{
public int x = 0;
public Test(int x){
this.x = x;
}
}
答案:BDE
第三题
已知如下的代码,
switch(m){
case 0: System.out.println("0");
case 1: System.out.println("1");
case 2: System.out.println("2");
case 3: System.out.println("3");break;
default: System.out.println("Other Condition");
}
A: 0
B: 1
C: 2
D: 3
E: 4
F: None
答案 F
第四题
面向对象的基本特性:
封装,继承,多态。
封装
封装是指隐藏对象的属性和细节,仅仅对外公开接口,例如封装成一个Class类。
继承
子类继承父类的方法和行为。例如Java中的继承关键字Extends。
多态
一个类有多种状态,例如Java中定义的接口,以及抽象类。
第五题
kibana支持哪些图形的生成
支持生成线形图、区域图和条形图
第六题
Es搜索速度为什么快于MySql
首先Es使用的是B+Tree索引,如下图所示
es使用的是倒排序索引,如下图所示
TreeIndex以树的形式保存在内存中,使用FST+压缩公共前缀的方法节省了内存,TermIndex查询到Term Dictionary 所在的block,去磁盘上查找Term减少I/O次数。
第七题
Redis和MySql有什么区别
Redis是key类型的NoSql,不支持复杂的查询,单线程事物只满足隔离性,writer操作不能满足持久化,占用内存很多,偶尔会把数据写入swap中。
MySql是符合笛卡尔积的关系型数据库,支持绝大多数的Sql,满足ACID以及各种隔离级别,数据能保证持久化,数据能够保存在磁盘中。
第八题
什么是ACID
ACID分别为原子性,一致性,隔离性,持久性。
第九题
客户请求访问HTML页面,与访问Servlet有什么异同?
A 相同,都使用HTTP协议。
B 区别,前者 Web 服务器直接返回 HTML 页面,后者 Web 服务器直接调用 Servlet 方法,由 Servlet 动态生成 HTML 页面。
C 区别: 后者需要在 Web.xml 中配置 URL 路径。
D 区别:前者使用 HTTP 协议,后者使用 RMI 协议。
答案 AD
第十题
i++ 和 ++i 有什么区别
i++ 先赋值再相加
++i 先相加再赋值
第十一题
哪些类可以用于处理 Unicode 编码
A: InputStreamReader
B:BufferedReader
C:Writer
D:PipedInputStream
答案: A
四个API如下
A、
InputStreanReader的构造函数:
InputStreamReader(InputStream in)
创建一个使用默认字符集的 InputStreamReader。
InputStreamReader(InputStream in, Charset cs)
创建使用给定字符集的 InputStreamReader。
InputStreamReader(InputStream in, CharsetDecoder dec)
创建使用给定字符集解码器的 InputStreamReader。
InputStreamReader(InputStream in, String charsetName)
创建使用指定字符集的 InputStreamReader。
B、
BufferedReader的构造函数:
BufferedReader(Reader in)
创建一个使用默认大小输入缓冲区的缓冲字符输入流。
BufferedReader(Reader in, int sz)
创建一个使用指定大小输入缓冲区的缓冲字符输入流。
C、
Writer的构造函数:
protected Writer()
创建一个新的字符流 writer,其关键部分将同步 writer 自身。
protected Writer(Object lock)
创建一个新的字符流 writer,其关键部分将同步给定的对象。
D、
PipedInputStream的构造函数:
PipedInputStream()
创建尚未连接的PipedInputStream。
PipedInputStream(int pipeSize)
创建一个尚未连接的PipedInputStream,并对管道缓冲区使用指定的管道大小。
PipedInputStream(PipedOutputStream src)
创建PipedInputStream,使其连接到管道输出流src。
PipedInputStream(PipedOutputStream src, int pipeSize)
创建一个PipedInputStream,使其连接到管道输出流src,并对管道缓冲区使用指定的管道大小。
第十二题
简单写下冒泡算法
private int[] bubbleSort(int[] array) {
int temp;
for (int i = 0; i < array.length - 1; i++) {
boolean Flag = false; // 是否发生交换。没有交换,提前跳出外层循环
for (int j = 0; j < array.length - 1 - i; j++) {
if (array[j] > array[j + 1]) {
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
Flag = true;
}
}
if (!Flag)
{
break;
}
}
return array;
}
第十三题
String s = new String("xyz") 创建了几个String Object
A 1
B 2
C 3
D 4
答案 A
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。