JAVA面试题大全(含答案)

JAVA面试题大全(含答案)


2024年4月27日发(作者:)

开发功底了。

启动中,startup nomount、 startup

mount 有什么差别?

解答: startup nomount:启动实例,读取参数

文件,分配内存空间,启动后台进程,打开跟踪

文件和报警文件。startup mount:装载数据库,

打开控制文件。nomount方式下还没有读取控制

文件,该选项用于在数据库的控制文件全部损

坏,需要重新创建数据库控制文件或创建一个新

的数据库时使用。mount 选项下并没有打开数

据文件,该选项可以用来修改数据库的运行模式

或进行数据库恢复。

启动中,、init.ora、

spfile.ora 这三个文件正确的先后顺序是

什么?

解答:启动数据库,使用startup命令,Oralce

将会按照以下顺序在缺省目录中搜索参数文件:

spfile.ora , ,init.ora a

94.说明Oracle数据库逻辑备份和物理备份的方

式。

解答:Oracle备份包括逻辑备份和物理备份。

1).逻辑备份

数据库的逻辑备份包含读一个数据库记录集和

将记录集写入文件。

a.输出(Export)输出可以是整个数据库、指定

用户或指定表。

b.输入(Import)输入将输出建立的二进制转储

文件读入并执行其命令。

2).物理备份

物理备份包含拷贝构成数据库的文件而不管其

逻辑内容。

Oracle支持两种不同类型的物理文件备份:脱机

备份(offline backup)和联机备份(online

backup)。

a.脱机备份: 脱机备份用在当数据库已正常关

闭,数据库处于”offline”时,要备份下列文件:

所有数据文件

所有控制文件

所有联机日志

(可选的)

b 联机备份:联机备份可用来备份任何运作在

ARCHIVELOG方式下的数据库。在这种方式

下,联机日志被归档,在数据库内部建立一个所

有作业的完整记录。联机备份过程具备强有力的

功能。第一,提供了完全的时间点(point-in-time)

恢复。第二,在文件系统备份时允许数据库保持

打开状态。

95.有2个类Cat及WhiteCat,代码如下:

public class Cat {

protected static String color = “random”;

public Cat() {

}

public void showCatColor() {

n(“Cat:” + color);

}

public static void showColor() {

n(“Cat:” + color);

}

}

public class WhiteCat extends Cat {

protected static String color = “white”;

public WhiteCat() {

super();

}

public void showCatColor() {

n(“WhiteCat:” + color);

}

public static void showColor() {

n(“WhiteCat:” + color);

}

}

请分析下面各段程序的运行结果

A.WhiteCat whiteCat = new WhiteCat(); Cat

cat

B.Cat cat = new Cat(); WhiteCat whiteCat =

(WhiteCat) cat;

lor(); tColor();

C.Cat cat = new WhiteCat(); WhiteCat

whiteCat = (WhiteCat) cat; lor();

tColor();

解答:A段执行的结果是:

= whiteCat; lor();

tColor();

Cat:random

WhiteCat:white

B段执行的结果是:

会抛出astException异常

C段执行的结果是:

Cat:random

WhiteCat:white

96、说说下面语句是否有错误,或可能出现的缺

陷,并指出错误,或缺陷在哪里?

public class MyFile implements Runnable{

public void run(){

while (true){

try{

FileReader fr=new FileReader(new

File(“”)) ;

String line=ne();

n(line);

}catch(IOException err) {

}

Sleep(1000); }

}

解答: ne()没有这个方法

(1000)需要用(1000);

97、判断下列语句是否正确,如果有错误,请指

出错误所在?

List a = new ArrayList();

(5);

解答:错误,默认封装int类型。

98、判断下列语句是否正确,如果有错误,请指

出错误所在?

void foo(final int []arg){

if ( > 1)

arg[0] = 5;

}

解答:正确

99、判断下列语句是否正确,如果有错误,请指

出错误所在?

interface A{

int add(final A a);

}

class B implements A{

long add(final A a){

return de() + de();

}

}

解答:返回值不是long类型

100、指出下面程序的运行结果:

class A{

static{

(“a”);

}

public A (){

(“x”);

}

}

class B extends A{

static{

(“b”);

}

public B (){

(“y”);

}

}

public class Test{

public static void main(String[] args){

A ab = new B ();

ab = new B ();

}

}

解答:abxyxy

101、下列代码的输出结果是什么?

public class MyFor {

public static void main (String argv[]){

int i; int j;

outer:for(i=1;i<3;i++)

inner:for(j=1;j<3;j++){

if (j==2) continue outer;

.println(“Value for i=”+i+”

for j=” +j);

}

Value

}

}

解答:Value for i=1 Value for j=1

Value for i=2 Value for j=1

102、查看下面的代码,写出可以使程序正常执

行的修改方法

class MyClass {

String s1;

3. String s2;

4. public static void main(String args[]) {

5. String s3;

6. n(“s1 =” + s1);

7. n(“s2 =” + s2);

8. n(“s3 =” + s3);

9. }

10.}

解答:删除第8行或者将第6行改为String s3 =

“”;

103、为了显示myStr = 23 这样的结果,写出在

控制台输入的命令

public class MyClass {

public static void main(String args[]) {

String s1 = args[0];

String s2 = args[1];

String myStr = args[2];

n(“myStr =” + s2 + myStr);

}

}

解答:java MyClass 1 2 3 4

104、写出下面代码的执行结果

public class MyClass {

static void aMethod(StringBuffer

StringBuffer sf2) {

(sf2);

sf2 = sf1;

sf1,

}

public static void main(String[] args){

StringBuffer sf1 = new StringBuffer(“A”);

StringBuffer sf2 = new StringBuffer(“B”);

aMethod(sf1,sf2);

.println(sf1+ “:”+sf2);

}

}

解答:AB:B

105、第3行中生成的object在第几行执行后成

为garbage collection的对象?

class MyClass {

2. public StringBuffer aMethod() {

3. StringBuffer sf = new StringBuffer(“Hello”);

4. StringBuffer[] sf_arr = new StringBuffer[1];

5. sf_arr[0] = sf;

6. sf = null;

7. sf_arr[0] = null;

8. return sf;

9. }

10.}

解答:第7行

106、写出执行下面的代码后的结果

public class MyClass {

public static void main(String args[]) {

v1 = new ();

ment(“Hello”);

ment(new Float(3.14f));

ment(10);

n(tAt(0) + “:” +

tAt(1) + “:”+ tAt(2));

}

}

解答:Hello : 3.14 : 10

107、写出执行下面代码后的正确结果

interface MyDB {

public void getConnection();

}

class MyDBDriver implements MyDB {

public void getConnection() {

n(“getConnection()”);

}

}

public class MyClass {

public static void aMethod(MyDB db) {

nection();

}

public static void main(String args[]) {

MyDBDriver db_driver = new MyDBDriver();

aMethod(db_driver);

}

}

解答:getConnection()

108、下列程序运行的结果是

class A {

class Dog {

private String name;

private int age;

private int step;

Dog(String s, int a) {

name = s;

age = a;

step = 0;

}

public void run(Dog fast) {

++;

}

}

public static void main(String args[]) {

A a = new A();

Dog d = Dog(“Tom”, 3);

= 25;

(d);

n();

}

}

解答:26

109、请看下列程序,运行结果是

class Super{

int i=10;

Super(){

print();

i=20;

}

void print(){

(i);

}

}

public class Sub extends Super{

int j=30;

Sub(){

print();

j=40;

}

void print(){

(j);

}

public static void main(String[] args){

(new Sub().j);

}

}

解答:03040

110、getSomething

果?

void makeConnection(String url) {

try {

getSomething();

}catch(NullPointerException e) {

n(“Invalid URL”) ;

return;

}catch(Exception e) {

()执行时发生

IllegalArgumentException会出现什么样的结


发布者:admin,转转请注明出处:http://www.yc00.com/news/1714225337a2405679.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信