4_JAVA+Oracle面试题(有答案)

2021-01-20 23:36

有用的面试题

基础测试题
卷面上不能出现任何的涂写文字,所有的答案要求写在答题纸上,考卷不得带走。
选择题
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


4_JAVA+Oracle面试题(有答案).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:彰显中医特色 打造一流医院——湖南省浏阳市中医医院简介

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: