- 相關(guān)推薦
2013中興筆試題JSD1309
1. 下列代碼的運行結果是:
public class GoTest {
public static void main(String[] args) {
Sente a = new Sente();
a.go();
Goban b = new Goban();
b.go();
Stone c = new Stone();
c.go();
}
}
class Sente implements Go {
public void go() {
System.out.println(“go in Sente”);
}
}
class Goban extends Sente {
public void go() {
System.out.println(“go in Goban”);
}
}
class Stone extends Goban implements Go {
}
interface Go {
public void go();
}
A. go in Goban
go in Sente
go in Sente
B. go in Sente
go in Sente
go in Goban
C. go in Sente
go in Goban
go in Goban
D. go in Goban
go in Goban
go in Sente
正確答案:C
2. A類(lèi)中有一個(gè)方法:protected int print(String str){},B類(lèi)繼承A類(lèi),以下方法能在B類(lèi)中重寫(xiě)A類(lèi)中print()方法的是: ()。
A.
public int print(String str){}
B.
private int print(String str){}
C.
private void print(String str){}
D.
public void print(String str){}
正確答案:A
3. List類(lèi)的對象list中的元素為:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],現在想返回該list對象的子集合[5,6,7,8],需要做的操作是:
A. list.subList(5, 8);
B. list.subList(5, 9);
C. list.subList(4, 8);
D. list.subList(4, 9);
正確答案:B
4. 下列代碼的運行結果是:
String test = “Test A. Test B. Test C.”;
String regex = “\\.\\s*”;
String[] result = test.split(regex);
for (String s : result)
System.out.print(s + ” “);
A. Test A Test B Test C
B. Test A. Test B. Test C.
C. Test . Test . Test .
D. A. B. C.
正確答案:A
5.
運行下面的程序:
int a = 100;
int b = 200;
a = a + b;
b = a – b;
a = a – b;
System.out.println(“a=” + a + “, b=” + b);
輸出的結果是:()。
A. a=100, b=300
B. a=100, b=200
C. a=200, b=100
D. a=300, b=200
正確答案:C
6.
類(lèi)A,B和C的定義如下:
public class A {
public void f() {
System.out.println(“A.f()”);
}
}
public class B extends A {
public void f() {
System.out.println(“B.f()”);
}
}
public class C {
public void g(A a) {
System.out.println(“g(A a)”);
a.f();
}
public void g(B b) {
System.out.println(“g(B b)”);
b.f();
}
}
運行下面程序:
C c = new C();
A a = new B();
c.g(a);
輸出的結果是:()。
A. g(A a)
A.f()
B. g(A a)
B.f()
C. g(B b)
A.f()
D. g(B b)
B.f()
正確答案:B
7.
下列代碼編譯和運行的結果是()
public class Foo {
public static void main(String[] args) {
java.util.List list = new java.util.ArrayList();
代碼java.util.List list = new java.util.ArrayList();行,編譯錯誤
public static void main(String[] args) {
RaceCar racer = new RaceCar();
Vehicle vehicle = new RaceCar();
System.out.println(racer.speed() + “, ” + car.speed() + “, ”
int[] oneArr = { 2, 11, 26, 27, 37, 44, 48, 60 };
int[] twoArr = { 19, 35, 49, 55, 58, 75, 83, 84, 91, 93 };
int[] threeArr = new int[oneArr.length + twoArr.length];
while (p < oneArr.length && q < twoArr.length) {
oneArr[p] < twoArr[q] ? oneArr[p++] : twoArr[q++];
System.arraycopy(oneArr, p, threeArr, p + q, oneArr.length – p);
System.arraycopy(twoArr, q, threeArr, p + q, twoArr.length – q);
System.out.println(Arrays.toString(threeArr));
A. [2,11,26,27,37,44,48,60,19,35,49,55,58,75,83,84,91,93];
B. [2,11,19,26,27,35,37,44,48,49,55,58,60,75,83,84,91,93];
C. [19,35,49,55,58,75,83,84,91,93,2,11,26,27,37,44,48,60];
D. [2,19,11,35,26,49,27,55,37,58,44,75,48,83,60,84,91,93];
public static void main(String[] args) {
如果想保證程序的輸出結果是[1,2],那么<插入代碼>處應填入的代碼是()。
Set set = new LinkedHashSet();
public int addOne(final int x){
public int addOne(final int x)
public static void main(String[] args) {
String[] tokens = test.split(“\\d”);
public void setWeight(int w) {
return Integer.toString(weight);
static void changePayload(Payload p) {
public static void main(String[] args) {
System.out.println(“The value of p is ” + p);
假設運行后輸出“The value of p is 420”,那么<插入代碼>處應填入代碼是:
System.out.print(str1.equals( str2));
String str3 = new String(“WhatisJava”);
System.out.println(str1.equals(str3));
public static void go(Long n) {
public static void go(Short n) {
public static void go(int n) {
public static void main(String[] args) {
System.out.println(“Inconceivable!”);
} else if (c instanceof Cup) {
System.out.println(“Dizzying intellect!”);
public static void main(String[] args) {
PoisonCup poison=new PoisonCup();
19. 下列關(guān)于IDE開(kāi)發(fā)環(huán)境Eclipse,說(shuō)法錯誤的是:()。
A. Eclipse可以通過(guò)插件(plugin)的方式擴展其功能。
B. Eclipse聯(lián)盟是由IBM公司捐資組建的。
20. 下列選項中的類(lèi),能正確實(shí)現java.lang.Runnable接口和java.lang.Clonable接口的是()。
public class Session implements Runnable, Clonable {
public class Session implements Runnable, implements Clonable {
public void run() { / do something */ }
public Object clone() { / make a copy */ }
public class Session implements Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { /* make a copy */ }
public class Session extends Runnable, Clonable {
21. 下面關(guān)于final說(shuō)法正確的是:()。
final修飾類(lèi)時(shí),該類(lèi)能被繼承。
當使用static final 修飾的常量時(shí),將采用編譯期綁定的方式。
當使用final和abstract共同修飾一個(gè)類(lèi)時(shí),final應至于abstract之前。
public static void main(String[] args) {
int[] two=new int[]{1,3,5,7,9};
System.arraycopy(one, 1, two, 2, 2);
System.out.println(Arrays.toString(two));
public static final String FOO = “foo”;
public static void main(String[] args) {
System.out.print(((Base) s).FOO);
public static final String FOO = “bar”;
String str = “**oracle***oracle*****oracle***”;
while ((index = str.indexOf(str1, index)) != -1) {
使類(lèi)Sprite編譯通過(guò),在<插入代碼>處應填入的代碼是:
A. Foo { public int bar() { return 1; } }
B. new Foo { public int bar() { return 1; } }
C. new Foo() { public int bar(){return 1; } }
D. new class Foo { public int bar() { return 1; } }
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, Calendar.SEPTEMBER);
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”);
System.out.println(sdf.format(c.getTime()));
public static void main(String argv){
System.out.println(“Hello cruel world”);
編譯無(wú)錯,但運行時(shí)指示沒(méi)有定義構造方法
編譯無(wú)錯,但運行時(shí)指示沒(méi)有正確定義main方法
public static void main(String[] args) {
StringBuffer a=new StringBuffer(“A”);
StringBuffer b=new StringBuffer(“B”);
public static void operator(StringBuffer x,StringBuffer y){
public static void main(String[] args) {
re = ((++i) + i == 2) ? true : false;
System.out.println(“i=” + i + “,re=”+re);
32. 數據類(lèi)型int、char和double所占用內存字節數分別是:()。
public static void main(String[] args) {
StaticFoo foo1 = new StaticFoo ();
StaticFoo foo2 = new StaticFoo ();
StaticFoo foo3 = new StaticFoo ();
System.out.print(foo3.num+”,”);
public WrappedString(String s) {
public static void main(String[] args) {
WrappedString ws1 = new WrappedString(“aardvark”);
WrappedString ws2 = new WrappedString(“aardvark”);
String s1 = new String(“aardvark”);
String s2 = new String(“aardvark”);
System.out.println(hs.size());
public void setAnchor(int x, int y) {
A. public class Circle implements Shape {
B. public abstract class Circle extends Shape {
C. public class Circle extends Shape {
D. public class Circle extends Shape {
public void draw() {/* code here */}
public boolean equals(Object obj) {
ArrayList list = new ArrayList();
如果控制臺輸出的結果是true,false,那么《插入代碼》處應填入的代碼是:
A. list.contains(new Foo(1)) + “,”+ set.contains(new Foo(1))
B. set.contains(new Foo(1)) + “,”+ list.contains(new Foo(1))
C. new Foo(1).equals (new Foo(1)) + “,”+ list.contains(new Foo(1))
D. new Foo(1).equals (new Foo(1)) + “,”+ set.contains(new Foo(1))
protected int method (int a, int b) {
A. public int method (int a, int b) { return 0; }
B. private int method(int a, int b) { return 0; }
C. private int method(int a, long b) { return 0; }
D. public short method(int a, int b) { return 0; }
A. “abc,,,bcd,,def,efg,,”.split(“[,]+”).length == 4;
B. “1st456″.matches(“\\d[a-z&&[^et]]{2,8}[0-9]+”);
C. “abcdefghijklmnopqrstuvwxyz”.substring(5,26).length() == 20;
歌德巴赫猜想是說(shuō)任何一個(gè)大于2的偶數都能表示為兩個(gè)素數之和,請編寫(xiě)一個(gè)Java程序,驗證1~100內歌德巴赫猜想的正確性。
public static void main(String[] args) {
System.out.println(“在1~100范圍內,現在開(kāi)始證實(shí)哥德巴赫猜想:”);
System.out.println(“在 1~100范圍內,哥德巴赫猜想是正確的。”);
System.out.println(“哥德巴赫猜想是錯誤的”);
* 判斷1~100范圍內的所有偶數是否符合哥德巴赫猜想,符合則返回true,反之則返回false
public static boolean testifyGuess(int low, int high) {
if ( 空白處1 ) // 在1~100之間選取大于2的偶數進(jìn)行哥德巴赫猜想測試
j++; // j用來(lái)控制輸出格式 ,每行輸出5個(gè)數據
public static boolean isGoldbach(int a) {
// 根據試題分析中的表達式,傳入相關(guān)的兩個(gè)參數
System.out.print(a + “=” + i + “+” + (a – i) + ” “);
* 判斷參數i是否是素數,是則返回true反之則返回false
public static boolean isPrime(int i) {
* 質(zhì)數又稱(chēng)素數。指在一個(gè)大于1的自然數中,除了1和此整數自身外,不能被其他自然數整除數
* 判斷i是否是素數的一個(gè)方法是看2~i-1之間有其因子(能被2整除),
isPrime(i-1) && isPrime(a – i)
System.out.println(“A.fun()”);
System.out.println(“B.fun()”);
System.out.println(“B.sun()”);
下列關(guān)于上述代碼中構造方法的描述,錯誤的是()。
實(shí)例化對象 a 時(shí),將默認調用父類(lèi)的無(wú)參構造方法
類(lèi) B中使用 super 關(guān)鍵字,是為了調用父類(lèi)的含有一個(gè)參數的構造方法
實(shí)例化對象 a 時(shí),父類(lèi)A和子類(lèi)B的構造方法都會(huì )被調用到
實(shí)例化父類(lèi)對象時(shí),調用父類(lèi) A 的構造方法;實(shí)例化子類(lèi)對象時(shí),則只調用子類(lèi)B的構造方法
public static void main(String[] args)
public static void main(String[] args)
如果將A類(lèi)定義成public abstract class A,那么方法fun必須定義成抽象方法
如果將A類(lèi)定義成public abstract class A,那么A類(lèi)中必須有一個(gè)抽象方法
如果將A類(lèi)中的方法fun定義成public abstract void fun(),那么A類(lèi)必須是抽象類(lèi)
如果將A類(lèi)定義成public abstract class A,那么A類(lèi)應然可以實(shí)例化對象
【中興筆試題JSD1309】相關(guān)文章:
中興2015筆試題08-02
中興筆試題08-18
中興硬件筆試試題07-31
中興通訊南京筆試題07-31
中興公共部分筆試題07-31
中興天津軟件筆試題08-10
中興人力資源筆試題08-02
中興筆試題及分析目分享07-31
中興2016年校招筆試題08-16