JAVA系統分析筆試題

選擇題

JAVA系統分析筆試題

1:public class x{

public object m(){

object o = new float(3.14f);//line 3

object [] oa = new object[1];//line 4

oa[0] = o;//line 5

o=null;//line 6

return oa[0];//line 7

}

}

when is the float object, created in line 3,eligible for garbage collection?

public class x{

public object m(){

object o = new float(3.14f);//line 3

object [] oa = new object[1];//line 4

oa[0] = o;//line 5

o=null;//line 6

return oa[0];//line 7

}

}

when is the float object, created in line 3,eligible for garbage collection?

after line 5.

after line 6

after line 7(that is,as the method returns)

r in this method

2:use the operator “>>” and “>>>”. which statement is true?

a.1010 0000 0000 0000 0000 0000 0000 0000 >> 4 give 0000 1010 0000 0000 0000 0000 0000 0000

b.1010 0000 0000 0000 0000 0000 0000 0000 >> 4 give 1111 1010 0000 0000 0000 0000 0000 0000

c.1010 0000 0000 0000 0000 0000 0000 0000 >>> 4 give 0000 0000 0000 0000 0000 0000 0000 0000

d.1010 0000 0000 0000 0000 0000 0000 0000 >>> 4 give 1111 1010 0000 0000 0000 0000 0000 0000

3:the following code is entire contents of a file called ,causes precisely one error during compilation:

class subclass extends baseclass{

}

class baseclass(){

string str;

public baseclass(){

tln(“ok”);}

public baseclass(string s){

str=s;}}

public class example{

public void method(){

subclass s=new subclass(“hello”);

baseclass b=new baseclass(“world”);

}

}

which line would be cause the error?

the following code is entire contents of a file called ,causes precisely one error during compilation:

class subclass extends baseclass{

}

class baseclass(){

string str;

public baseclass(){

tln(“ok”);}

public baseclass(string s){

str=s;}}

public class example{

public void method(){

subclass s=new subclass(“hello”);

baseclass b=new baseclass(“world”);

}

}

which line would be cause the error?

a.9

b.10

c.11

d.12

4:what will be the result of executing the following code?

boolean a = true;

boolean b = false;

boolean c = true;

if (a == true)

if (b == true)

if (c == true) tln("some things are true in this world");

else tln("nothing is true in this world!");

else if (a && (b = c)) tln("it's too confusing to tell what is true and what is false");

else tln("hey this won't compile");

choices:

what will be the result of executing the following code?

boolean a = true;

boolean b = false;

boolean c = true;

if (a == true)

if (b == true)

if (c == true) tln("some things are true in this world");

else tln("nothing is true in this world!");

else if (a && (b = c)) tln("it's too confusing to tell what is true and what is false");

else tln("hey this won't compile");

choices:

code won't compile

b."some things are true in this world" will be printed

c."hey this won't compile" will be printed

of these

5:give the following java source fragement:

//point x

public class interesting{

//do something

}

which statement is correctly java syntax at point x?

give the following java source fragement:

//point x

public class interesting{

//do something

}

which statement is correctly java syntax at point x?

ic class myclass{//do other thing…}

ic int pi=3.14

s myclass{//do something…}



6:public class parent {

int change() {…}

}

class child extends parent {

}

which methods can be added into class child?

ic int change(){}

ract int chang(){}

ate int change(){}



7:給出下面的代碼片斷。。。下面的哪些陳述為錯誤的?

1) public void create() {

2) vector myvect;

3) myvect = new vector();

4) }

給出下面的代碼片斷。。。下面的哪些陳述為錯誤的?

1) public void create() {

2) vector myvect;

3) myvect = new vector();

4) }

a.第二行的聲明不會為變量myvect分配內存空間。

b.第二行語句創建一個vector類對象。

c.第三行語句創建一個vector類對象。

d.第三行語句為一個vector類對象分配內存空間

8:what is written to the standard output given the following statement:tln(4|7);

select the right answer:

a.4

b.5

c.6

d.7

9:which fragments are not correct in java source file?

age testpackage; public class test{//do something...}

rt .*; package testpackage; public class test{// do something...}

rt .*; class person{// do something...} public class test{// do something...}

rt .*; import .*; public class test{// do something...}

10:give the following java class:

public class example{

static int x[]=new int[15];

public static void main(string args[]){

tln(x[5]);

}

}

which statement is corrected?

give the following java class:

public class example{

static int x[]=new int[15];

public static void main(string args[]){

tln(x[5]);

}

}

which statement is corrected?

compile, some error will occur.

run, some error will occur.

ut is zero.

ut is null.

11:使用 jdbc 可以做到的是

a.把二進制代碼傳送到任何關係數據庫中

b.把 java 源代碼傳送到任何關係數據庫中

c.把表單信息傳送到任何關係數據庫中

d.很容易地把 sql 語句傳送到任何關係數據庫中

12:which method you define as the starting point of new thread in a class from which new the thread can be excution?

ic void start()

ic void run()

ic void runnable()

ic static void main(string args[])

13:which statements about java code security are not true?

bytecode verifier loads all classes needed for the execution of a program.

uting code is performed by the runtime interpreter.

runtime the bytecodes are loaded, checked and run in an interpreter.

class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.

14:關於垃圾收集的哪些敍述是對的。

a.程序開發者必須自己創建一個線程進行內存釋放的工作

b.垃圾收集將檢查並釋放不再使用的內存。

c.垃圾收集允許程序開發者明確指定並立即釋放該內存。

d.垃圾收集能夠在期望的時間釋放被java對象使用的內存。

15:give the following java class:

public class example{

public static void main(string args[]){

static int x[] = new int[15];

tln(x[5]);

}

}

which statement is corrected?

give the following java class:

public class example{

public static void main(string args[]){

static int x[] = new int[15];

tln(x[5]);

}

}

which statement is corrected?

compile, some error will occur.

run, some error will occur.

ut is zero.

ut is null.

16:select valid identifier of java:

select valid identifier of java:

a.%passwd

b.3d_game

c.$charge



簡答題

17:abstract class和interface有什麼區別?

18:hibernate中,什麼情況下,對象的狀態可以由持久的變為託管的?

19:兩個數相乘,小數點後位數沒有限制,請寫一個高精度算法。

20:求符合指定規則的數。

給定函數d(n) = n n的各位之和,n為正整數,如 d(78) = 78 7 8=93。 這樣這個函數

可以看成一個生成器,如93可以看成由78生成。

定義數a:數a找不到一個數b可以由d(b)=a,即a不能由其他數生成。現在要寫程序,找出

1至10000裏的所有符合數a定義的數。

輸出:

1

3