亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

求職寶典

6.2 筆試真題 & 詳解

一、 單選題(18分,每小題個2分)

1.關(guān)于軟件測試的目的,下面觀點錯誤的是()

A、未來發(fā)現(xiàn)錯誤而執(zhí)行程序的過程

B、一個好的測試用例能夠發(fā)現(xiàn)至今尚未發(fā)現(xiàn)的錯誤

C、證明程序是正確、沒有錯誤的

D、一個成功的測試用例是發(fā)現(xiàn)了至今尚未發(fā)現(xiàn)的錯誤的測試

2.Given:

Integer i = new Integer(42);

Long l = new Long(42);

Double d = new Double(42.0);

Which expression evaluates to True?

A. (i == l)

B. (i == d)

C. (d == 1)

D. (i.equals(d))

E. (d.equals(l))

F. (i.equals(l))

G. (l.equals(42L))

3.What happens when you try to compile and run the following application?Choose all

Correct options.

1. public

class Z {

2. public

static

void main(String[] args) {

3. new Z();

4. }

5.

6. Z() {

7. Z alias1 =

this;

8. Z alias2 =

this;

9.

synchronized (alias1) {

10.

try {

11. alias2.wait();

12. System.out.println("DONE WAITING");

13. }

14.

catch (InterruptedException e) {

15. System.out.println("INTERRUPTED");

16. }

17.

catch (Exception e) {

18. System.out.println("OTHER EXCEPTION");

19. }

20.

finally {

21. System.out.println("FINALLY");

22. }

23. }

24. System.out.println("ALL DONE");

25. }

26. }

A.The application compiles and prints “DONE WAITING”

B.The application compiles but doesn’t print anything

C.The application compiles and print “FINALLY”

D.The application compiles and print “ALL DONE”

E.The application compiles and print “INTERRUPTED”

F.The application compiles and print “DONE WAITING” and “FINALLY”

4.Consider the following classes:

1. class Person{

2.

public

void printValue(

int i,

int j){/*.....*/}

3.

public

void printValue(

int i){/*....*/}

4. }

5. public

class Teacher

extends Person{

6.

public

void printValue(){/*...*/}

7.

public

void printValue(

int i){/*...*/}

8.

public

void printValue(String i){/*...*/}

9.

public

static

void main(String args[]){

10. Person t =

new Teacher();

11.

char ch = 'y';

12. t.printValue(ch);

13. }

14.}

Which of the statements below is true?

A. Line 7 will not compile, because void methods cannot be overridden

B. Line 12 will not compile, because there is no version of printValue() that takes a char argument

C. The code will compile but will throw an exception at line 12 at runtime

D. The statement on line 12 will invoke the method on line 8

E. The statement on line 12 will invoke the method on line 2

F. The statement on line 12 will invoke the method on line 3

G. The statement on line 12 will invoke the method on line 7

5.Consider the following statement, choose all correct options

You are given a class hierarchy with an instance of the Class Dog. The class Dog is a child of

Mammal and the class Mammal is a child of the class Vertebrate. The class Vertebrate has a method called move which prints out the string “move” . The class Mammal overrides this method and prints out the string”walks”. The class Dog overrides this method and prints out the string “walks on paws”.

Given an instance(dog) of the class Dog,how can you access the ancestor method move in Vertebrate so it prints out the string “move”;

A. dog.super().super().move();

B. dog.parent().parent().move();

C. dog.move();

D. none of the above

6.What will happen when you attempt to compile and run the following code.

public

class Test {

public

static

void main(String argv[]) {

HHQ ht =

new HHQ("my name");

ht.start();

}

}

class HHQ

extends Thread {

private String name = "";

HHQ(String s) {

name = s;

}

public

void run() {

inner();

System.out.println("finished");

}

public

void inner() {

while (

true) {

try {

System.out.println("waiting");

wait();

}

catch (InterruptedException ie) {

}

System.out.println(name);

notifyAll();

}

}

}

A. It will cause a compile time error

B. Compilation and output of “waiting”

C. Compilation and output of “waiting” followed by “finished”

D. Runtime error, output of “waiting” and an exception will be thrown

7.Which of the following most closely describes the process of overriding?

A.A class with the same name replaces the functionality of a class defined earlier in the hierarchy

B.A method with the same name completely replaces the functionality of a method earlier in the hierarchy

C.A method with the same name but different parameters gives multiple uses for the same method name

D.A class is prevented from accessing methods in its immediate ancestor

8.Given the following code:

1 class A{

2

public

void process(){System.out.print("A");}}

3 class B

extends A{

4

public

void process()

throws IOException{

5

super.process();

6 System.out.print("B");

7

throw

new IOException();

8 }

9

public

static

void main(String[] args) {

10

try{

11

new B().process();

12 }

catch(IOException e){

13 System.out.println("Exception");

14 }

15 }

16 }

What will happen when you attempt to compile and run it?

A. The program will run and output “A”,”B” and “Exception”

B. The program will run and output “A”

C. The program will run and output “B” and “Exception”

D. Compilation fails because of an error in line 11

E. Compilation fails because of an error in line 4

F. An IOException will thrown at runtime

9.What will happen when you attempt to compile and run the following code in JDK 5 environment?

1.

public

class Test{

2.

public

static

void increase(Integer i){

3. i++;

4.}

5.

public

static

void main(String args[]){

6. Integer i =

new Integer(0);

7. increase(i);

8. System.out.println(i);

9. }

10.}

A.Compilation fails because of an error in line 7

B.Compilation fails because of an error in line 3

C.The program will run and output “1”

D.The program will run and output a random number

E.The program will run and output “0”

二、不定項選擇題(18分,每小題各2分)

1.下述表達正確的有()

A、單元測試應(yīng)該由試人員進行測試

B、軟件質(zhì)量是不可量化的

C、開發(fā)人員應(yīng)該對代碼質(zhì)量負(fù)最主要的責(zé)任

D、軟件配置管理的好壞對軟件的最終質(zhì)量沒有影響

E、軟件運行性能是由硬件配置所制約的,與程序所用的數(shù)據(jù)結(jié)構(gòu)與算法無關(guān)

2.Which of the following demonstrate a “has a”relationship?

A、public interface Person{ }

public class Employee extends Person{ }

B、public interface Shape { }

public interface Rectangle extends Shape{ }

C、public interface Colorable{ }

public class Shape implements Colorable{ }

D、public class Species{ }

public class Animal{

private Species species;

}

E、interface Component{ }

class Container implements Componet{

private Component[] children;

}

3.Which of the following are true for the class java.util.TreeSet?

A.The elements in the collection are ordered

B.The collection is guaranteed to be immutable

C.The elements in the collection are guaranteed to be unique

D.The elements in the collection are accessed using a unique key

E.The elements in the collection are guaranteed to by synchronized

4.Given the following code fragment:

1.

public

void create(){

2. Vector myVect;

3. myVect =

new Vector();

4.}

Which of the following statement are true?

A. The statement on line 2 creates an object of class Vector

B. The declaration on line 2 does not allocate memory space for the variable myVect

C. The declaration on line 2 allocates memory space for a reference to a Vector object

D. The statement on line 3 create an object of class Vector

E. The statement on line 3 allocates memory space for an object of class Vector

5.Given the following code:

class Base{

static

int oak=99;

}

public

class Doverdale

extends Base{

public

static

void main(String argv[]){

Doverdale d =

new Doverdale();

d.amethod();

}

public

void amethod(){

//Here

}

}

Which of the following if placed after the comment//Here,will compile and modify the value of the variable oak?

A. super.oak=1;

B. oak=33;

C. Base.oak=22;

D. Oak=50.1;

6.Which of the following statements are true about a variable created with the static modifier?

A.Once assigned the value of a static variable can’t be altered

B.A static variable created in a method will keep the same value between calls

C.Only one instance of a static variable will exist for any amount of class instances

D.The static modifier can only be applied to a primitive value

7.Given the following class:

public

class A{

public

static

void main(String argv[]){

boolean b1 =

true;

if((b1==

true)||place(

true)){

System.out.println("Hello True");

}

if(b1 | place((String)

null)){

System.out.println("Hello Null");

}

}

public

static

boolean place(

boolean location){

if(location!=

true){

System.out.println("world True");

}

System.out.println("World True");

return

true;

}

public

static

boolean place(String str){

if(str ==

null | str.length() == 0){

System.out.println("World Null");

}

System.out.println("World String");

return

true;

}

What will happen when you attempt to compile and run it?

A. Compile fails

B. Output of “Hello True”

C. Output of “World Boolean” followed by “Hello True”,”World Null”,”World String” and “Hello Null”

D. Output of “Hello True” followed by “Hello Null”

E. Output of “Hello True”, then an exception is thrown at runtime

F. Output of “Hello True“ followed by “World null”,”World String” and “Hello Null”

8.Which statement are true about the garbage collection mechanisms?

A.The garbage collection mechanism release memory at predictable times

B.A correct program must not depend upon the timing or order of garbage collection

C.Garbage collection ensures that a program will not run out of memory during execution

D.The programmer can indicate that a reference through a local variable is no longer going to Java objects

E.The programmer has a mechanism that explicitly and immediately frees the memory used by Java objects

F.The garbage collection system never reclaims memory from objects while are still accessible to running user threads

9.What will happen when you attempt to compile and run the following code?

1.pu

blic

class Test{

2.

public

static String hello(String[] strs,String s2){

3. strs[0] = "<" + strs[0] + ">";

4. s2.toUpperCase();

5.

return s2;

6.}

7.

public

static

void main(String args[]){

8. String a =

new String("t");

9. String[] b =

new String[]{"t"};

10. String c = a.intern();

11.

if(a.equals(b[0])){

12. System.out.print("1");

13. }

14.

if(b[0] == c){

15. System.out.print("2");

16. }

17.

if(a == c){

18. System.out.print("3");

19. }

20. a = hello(b,c);

21. System.out.print(a);

22. System.out.print(b[1]);

23. System.out.print(c);

24. }

25.}

A.The program will run and output “12t<t>t”

B.The program will run and output “123T<t>t”

C.The program will run and output “12T<t>t”

D.Compilation fails because of an error in line 4

E.Compilation fails because of an error in line 9

F.The program will run and output “12ttt”

三、填空題(每空3分,共51分)

1、如下的代碼實現(xiàn)了先進先出隊列,請按注釋要求填空。(每空各3分,共9分)

class FifoQueue{

private

transient Node head;

private

transient Node last;

Node enq(Object x){ //入隊

Node p =

new Node(x);

if(last ==

null)

last = head = p;

else

[1] ; //請在此補充一條語句

return p;

}

Node deq(){ //出隊

Node p = head;

if( [2] ){ //請在此補充一條表達式

if((head = p.next) ==

null)

[3]; //請在此補充一條語句

p.next =

null;

}

return p;

}

static

final

class Node{

/** The item being transferred */

Object item;

/** Next node in wait queue */

Node next;

/** Creates a node with initial item */

Node(Object x) { item = x; }

}

}

2.如下的代碼采用合并排序?qū)?shù)組進行排序,請按注釋要求填空。(每空各3分,共21分)

import java.lang.reflect.Array;

import java.util.Random;

public

class Test{

//將數(shù)組src中的Integer類型的元素按增序排列

public

static

void main(String[] argv){

Object[] src =

new Object[100];

for(

int i = 0;i < src.length;i++){

src[i] =

new Random().nextInt();

}

Object[] aux = cloneArray(src);

mergeSort(aut,src,0,src.length);

for(

int i = 0;i < src.length;i++){

System.out.print(src[i] + ",");

}

}

/**

* Src is the source array that starts at index 0.數(shù)組元素實現(xiàn)java.lang.Comparable接口

* Dest is the destination array that starts at index 0.數(shù)組元素實現(xiàn)java.lang.Comparable接口

* low is the index in dest to start sorting

* high is the end index in dest to end sorting

*/

private

static

void mergeSort(Object[] src,Object[] dest,

int low,

int high){

int length = high - low;

//Insertion sort on smallest arrays. 當(dāng)待排序元素的個數(shù)少于5時,采用插入排序

if(length < 5){

for(

int i = low;i < high; i++){

if(((Comparable)dest[j-1]).compareTo(dest[j]) > 0){

Object t = dest[j];

[4]; //請在此補充一條語句

[5]; //請在此補充一條語句

}

}

return;

}

//Recursively sort halves of dest into src

int mid = (low + high) >> 1;

mergeSort(dest,src,low,mid);

[6]; //請在此補充一條語句

//If list is already sorted,just copy from src to dest.This is an

//optimization that results in faster sorts for nearly ordered lists.

if( [7] ){ //請在此補充一條表達式

System.arraycopy(src, low, dest, low, length);

return;

}

//Merge sorted halves (now in src) into dest

int p = low;

[8]; //請在此補充一條語句

for(

int i = low;i < high; i++){

if( [9] //請在此補充一條表達式

|| p < mid && ((Comparable)src[p]).compareTo(src[q]) <=0){

dest[i] = src[p++];

}

else {

[10]; //請在此補充一條語句

}

}

}

/**

*Clones an array within the specified bounds. This method assumes that a

*is an array.

*/

private

static <T> T[] cloneArray(T[] a){

int n = a.length;

T[] result = (T[])Array.newInstance(a.getClass().getComponentType(), n);

System.arraycopy(a, 0, result, 0, n);

return result;

}

}

3.以下為JDK1.5中java.util.HashMap(哈希表)的實現(xiàn),請根據(jù)給出的代碼片段,完成put方法的填空(每空各3分,共6分)

package java.util;

import java.io.*;

import java.security.KeyStore.Entry;

public

class HashMap<K,V>

extends AbstractMap<K,V>

implements Map<K,V>,Cloneable,Serializable

{

/**

* The table,resized as necessary.Length must always be a power of two.

*/

transient Entry[] table;

/**

*The number of key-value mappings contained in this identity hash map.

*/

transient

int size;

/**

* The next size value at which to resize (capacity * load factor).

*/

int threshold;

/**

* The number of times this HashMap has been structurally modified

* Structural modifications are those that change te number of mappings in

* the HashMap or otherwise modify its internal structure(e.g.

* rehash).This field is used to make iterators on Collection-views of

* the HashMap fail-fast. (See concurrentModificationException)

*/

transient

volatile

int modCount;

//其它代碼段...省略

/**

* Associates the specified value with the specified key in this map.

* If the map previously contained a mapping for this key,the old

* value is replaced.

*

*

@param key key with which the specified value is to be associated.

*

@param value value to be associated with the specified key.

*

@return previous value associated with specified key,or null

* if there was no mapping for key.A null</tt>return can

* alse indicate that the hashMap previously associated

* null with the specified key.

*/

public V put(K key,V value){

if(key ==

null)

return putForNullkey(value);

int hash =hash( [11] ); //請在此補充一條表達式

int i = indexFor(hash,table.length);

for(Entry<K,V> e = talbe[i];e !=

null;e=e.next){

Object k;

if(e.hash == hash && ((k = e.key) == key || [12] )){ //請在此補充一條表達式

V oldValue = e.value;

e.value = value;

e.recordAccess(

this);

return oldValue;

}

}

modCount++;

addEntry(hash,key,value,i);

return

null;

}

static

int hash(

int h){

h ^= (h >>> 20) ^ (h >>> 12);

return h ^ (h >>> 7) ^ (h >>> 4);

}

/**

* Returns index for hash code h.

*/

static

int indexFor(

int h,

int length){

return h & (length-1);

}

}

4.請閱讀以下代碼,并根據(jù)代碼上下文完成填空。 (每空各3分,共15分)

package examination;

import java.util.concurrent.locks.Condition;

import java.util.concurrent.locks.Lock;

import java.util.concurrent.locks.ReentrantLock;

public

class ThreadSafeBuffer{

final Lock lock =

new ReentrantLock();

final Condition notFull = lock.newCondition();

final Condition notEmpty = lock.newCondition();

final Object[] data =

new Object[1024];

int putptr,takeptr,count;

public

void put(Object x)

throws InterruptedException {

lock.lock();

try{

[13]{ //請在此補充一條語句

[14]; //請在此補充一條語句

}

data[putptr] = x;

if(++putptr == data.length){

putptr = 0;

}

++count;

[15]; //請在此補充一條語句

}

finally {

lock.unlock();

}

}

public Object take()

throws InterruptedException{

lock.lock();

try{

[16]{ //請在此補充一條語句

[17]; //請在此補充一條語句

}

Object x = data[takeptr];

if(++takeptr == data.length){

takeptr = 0;

}

--count;

notFull.signal();

return x;

}

finally {

lock.unlock();

}

}

}

更多柳工機械筆試真題及答案:https://bbs.yjbys.com/bjfx/

 

《柳工機械求職寶典》

《柳工機械求職寶典Word下載》

《柳工機械求職寶典PDF下載》

Copyright©2006-2024應(yīng)屆畢業(yè)生網(wǎng)yjbys.com版權(quán)所有