4_JAVA+Oracle面试题(有答案)
有用的面试题
基础测试题
卷面上不能出现任何的涂写文字,所有的答案要求写在答题纸上,考卷不得带走。
选择题
1、 What will happen when you attempt to compile and run the following code? (D)
public class Static {
static {
int x = 5; // 在static内有效
}
static int x, y; // 初始化为0
public static void main(String args[]) {
x--; // -1
myMethod();
System.out.println(x + y + ++x);
}
public static void myMethod() {
y = x++ + ++x; // y=-1+1 x=1
}
}
A.compiletime errorB.prints: 1C.prints: 2D、prints: 3E、prints: 7F、prints: 8
将以上的程序分步进行执行:
1、static int x, y;?x = 0 ;y = 0 ;
2、x--;?x = -1 ;y = 0 ;
3、y = x++ + ++x;?x = 1 ;y = 0 ;
4、System.out.println(x + y + ++x);?3
2、Given the following code, what will be the output? (A)
class Value {
public int i = 15;
}
public class Test {
public static void main(String argv[]) {
Test t = new Test();
t.first();
}
public void first() {
int i = 5;
Value v = new Value();
v.i = 25;
second(v, i);
System.out.println(v.i);
}
public void second(Value v, int i) {
i = 0;
v.i = 20;
Value val = new Value();
v = val;
System.out.println(v.i + " " + i);
}
}
A、15 0 20B、15 0 15C、20 0 20D、0 15 20
3、What will happen when you attempt to compile and run the following code? (A)
class MyParent {
int x, y;
MyParent(int x, int y) {
this.x = x;
this.y = y;
}
public int addMe(int x, int y) {
return this.x + x + y + this.y;
}
public int addMe(MyParent myPar) {
return addMe(myPar.x, myPar.y);
}
}
class MyChild extends MyParent {
int z;
MyChild(int x, int y, int z) {
super(x, y);
this.z = z;
}
public int addMe(int x, int y, int z) {
return this.x + x + this.y + y + this.z + z;
}
public int addMe(MyChild myChi) {
return addMe(myChi.x, myChi.y, myChi.z);
}
public int addMe(int x, int y) {
return this.x + x + this.y + y;
}
}
public class MySomeOne {
public static void main(String args[]) {
MyChild myChi = new MyChild(10, 20, 30);
MyParent myPar = new MyParent(10, 20);
int x = myChi.addMe(10, 20, 30);
int y = myChi.addMe(myChi);
int z = myPar.addMe(myPar);
System.out.println(x + y + z);
}
}
A、300B、240C、120D、180E、compile errorF、none of the above
class MyParent {
int x, y;
MyParent(int x, int y) {// 1020
this.x = x;
this.y = y;
}
public int addMe(int x, int y) {
return this.x + x + y + this.y;
}
public int addMe(MyParent myPar) {
return addMe(myPar.x, myPar.y);
}
}
class MyChild extends MyParent {
int z;
MyChild(int x, int y, int z) {// 102030
super(x, y);
this.z = z;
}
public int addMe(int x, int y,
int z) {
return this.x + x + this.y + y + this.z + z;
//101020203030-->120 + 120
}
public int addMe(MyChild myChi) {
retur
有用的面试题
n addMe(myChi.x, myChi.y, myChi.z);
}
public int addMe(int x, int y) {
return this.x + x + this.y + y;
}
}
public class MySomeOne {
public static void main(String args[]) {
MyChild myChi = new MyChild(10, 20, 30);
MyParent myPar = new MyParent(10, 20);
int x = myChi.addMe(10, 20, 30);// 120
int y = myChi.addMe(myChi);// 120
int z = myPar.addMe(myPar);// 60
System.out.println(x + y + z);
}
}
4、What will happen when you attempt to compile and run the following code? (E)
interface MyInterface {
}
public class MyInstanceTest implements MyInterface {
static String s;
public static void main(String args[]) {
MyInstanceTest t = new MyInstanceTest();
if (t instanceof MyInterface) {
System.out.println("I am true interface");
} else {
System.out.println("I am false interface");
}
if (s instanceof String) {
System.out.println("I am true String");
} else {
System.out.println("I am false String");
}
}
}
A、compile time error
B、runtime error
C、prints: “I am true interface” followed by “I am true String”
D、prints: “I am false interface” followed by “I am false String”
E、prints: “I am true interface” followed by “I am false String”
F、prints: “I am false interface” followed by “I am true String”
只有当一个对象实例化之后才有可能知道其具体的类型。
5、What results from attempting to compile and run the following code? (D)
public class Ternary {
public static void main(String args[]) {
int a = 5;
System.out.println("Value is - " + ((a < 5) ? 9.0 : 9)); ? 数据类型的自动转换 9.0
}
}
A、print:Value is -9B、print:Value is -5C、Compilation errorD、None of these
6、What will be the result of executing the following code? (D)
public static void main(String args[]) {
char digit = 'a';
for (int i = 0; i < 10; i++) {
switch (digit) {
case 'x': {
int j = 0;
System.out.println(j);
}
default: {
int j = 100;
System.out.println(j);
}
}
}
int i = j;
System.out.println(i);
}
A、100 will be printed 11 times.
B、100 will be printed 10 times and then there will be a runtime exception
C、The code will not compile because the variable i cannot be declared twice within the mani() method.
D、The code will not compile because the variable j cannot be declared twice within the switch statement.
E、None of these.
7、Which of the following collection classes from java.util package are Thread safe? (D)
A、VectorB、A
…… 此处隐藏:4482字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [资格考试]石油钻采专业设备项目可行性研究报告编
- [资格考试]2012-2013学年度第二学期麻风病防治知
- [资格考试]道路勘测设计 绪论
- [资格考试]控烟戒烟知识培训资料
- [资格考试]建设工程安全生产管理(三类人员安全员
- [资格考试]photoshop制作茶叶包装盒步骤平面效果
- [资格考试]授课进度计划表封面(09-10下施工)
- [资格考试]麦肯锡卓越工作方法读后感
- [资格考试]2007年广西区农村信用社招聘考试试题
- [资格考试]软件实施工程师笔试题
- [资格考试]2014年初三数学复习专练第一章 数与式(
- [资格考试]中国糯玉米汁饮料市场发展概况及投资战
- [资格考试]塑钢门窗安装((专项方案)15)
- [资格考试]初中数学答题卡模板2
- [资格考试]2015-2020年中国效率手册行业市场调查
- [资格考试]华北电力大学学习实践活动领导小组办公
- [资格考试]溃疡性结肠炎研究的新进展
- [资格考试]人教版高中语文1—5册(必修)背诵篇目名
- [资格考试]ISO9001-2018质量管理体系最新版标准
- [资格考试]论文之希尔顿酒店集团进入中国的战略研
- 全国中小学生转学申请表
- 《奇迹暖暖》17-支2文学少女小满(9)公
- 2019-2020学年八年级地理下册 第六章
- 2005年高考试题——英语(天津卷)
- 无纺布耐磨测试方法及标准
- 建筑工程施工劳动力安排计划
- (目录)中国中央空调行业市场深度调研分
- 中国期货价格期限结构模型实证分析
- AutoCAD 2016基础教程第2章 AutoCAD基
- 2014-2015学年西城初三期末数学试题及
- 机械加工工艺基础(完整版)
- 归因理论在管理中的应用[1]0
- 突破瓶颈 实现医院可持续发展
- 2014年南京师范大学商学院决策学招生目
- 现浇箱梁支架预压报告
- Excel_2010函数图表入门与实战
- 人教版新课标初中数学 13.1 轴对称 (
- Visual Basic 6.0程序设计教程电子教案
- 2010北京助理工程师考试复习《建筑施工
- 国外5大医疗互联网模式分析