- 相關推薦
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類中有一個方法:protected int print(String str){},B類繼承A類,以下方法能在B類中重寫A類中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類的對象list中的元素為:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],現(xiàn)在想返回該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.
類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. 下列關于IDE開發(fā)環(huán)境Eclipse,說法錯誤的是:()。
A. Eclipse可以通過插件(plugin)的方式擴展其功能。
B. Eclipse聯(lián)盟是由IBM公司捐資組建的。
20. 下列選項中的類,能正確實現(xiàn)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 {
當使用static final 修飾的常量時,將采用編譯期綁定的方式。
當使用final和abstract共同修飾一個類時,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) {
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”);
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. 數(shù)據(jù)類型int、char和double所占用內存字節(jié)數(shù)分別是:()。
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;
歌德巴赫猜想是說任何一個大于2的偶數(shù)都能表示為兩個素數(shù)之和,請編寫一個Java程序,驗證1~100內歌德巴赫猜想的正確性。
public static void main(String[] args) {
System.out.println(“在1~100范圍內,現(xiàn)在開始證實哥德巴赫猜想:”);
System.out.println(“在 1~100范圍內,哥德巴赫猜想是正確的。”);
System.out.println(“哥德巴赫猜想是錯誤的”);
* 判斷1~100范圍內的所有偶數(shù)是否符合哥德巴赫猜想,符合則返回true,反之則返回false
public static boolean testifyGuess(int low, int high) {
if ( 空白處1 ) // 在1~100之間選取大于2的偶數(shù)進行哥德巴赫猜想測試
j++; // j用來控制輸出格式 ,每行輸出5個數(shù)據(jù)
public static boolean isGoldbach(int a) {
// 根據(jù)試題分析中的表達式,傳入相關的兩個參數(shù)
System.out.print(a + “=” + i + “+” + (a – i) + ” “);
* 判斷參數(shù)i是否是素數(shù),是則返回true反之則返回false
public static boolean isPrime(int i) {
// 1本身不是素數(shù),因此需把這個特殊的數(shù)字拋出
* 質數(shù)又稱素數(shù)。指在一個大于1的自然數(shù)中,除了1和此整數(shù)自身外,不能被其他自然數(shù)整除數(shù)
* 判斷i是否是素數(shù)的一個方法是看2~i-1之間有其因子(能被2整除),
* 有則不是素數(shù)返回false,反之則返回true
isPrime(i-1) && isPrime(a – i)
System.out.println(“A.fun()”);
System.out.println(“B.fun()”);
System.out.println(“B.sun()”);
類 B中使用 super 關鍵字,是為了調用父類的含有一個參數(shù)的構造方法
實例化父類對象時,調用父類 A 的構造方法;實例化子類對象時,則只調用子類B的構造方法
public static void main(String[] args)
public static void main(String[] args)
如果將A類定義成public abstract class A,那么方法fun必須定義成抽象方法
如果將A類定義成public abstract class A,那么A類中必須有一個抽象方法
如果將A類中的方法fun定義成public abstract void fun(),那么A類必須是抽象類
如果將A類定義成public abstract class A,那么A類應然可以實例化對象
【中興筆試題JSD1309】相關文章:
中興2015筆試題08-02
中興筆試題08-18
中興硬件筆試試題07-31
中興通訊南京筆試題07-31
中興公共部分筆試題07-31
中興天津軟件筆試題08-10
中興人力資源筆試題08-02
中興筆試題及分析目分享07-31
中興2016年校招筆試題08-16