- 相关推荐
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],现在想返回该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开发环境Eclipse,说法错误的是:()。
A. Eclipse可以通过插件(plugin)的方式扩展其功能。
20. 下列选项中的类,能正确实现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. 数据类型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;
歌德巴赫猜想是说任何一个大于2的偶数都能表示为两个素数之和,请编写一个Java程序,验证1~100内歌德巴赫猜想的正确性。
public static void main(String[] args) {
System.out.println(“在1~100范围内,现在开始证实哥德巴赫猜想:”);
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的偶数进行哥德巴赫猜想测试
public static boolean isGoldbach(int a) {
System.out.print(a + “=” + i + “+” + (a – i) + ” “);
* 判断参数i是否是素数,是则返回true反之则返回false
public static boolean isPrime(int i) {
* 质数又称素数。指在一个大于1的自然数中,除了1和此整数自身外,不能被其他自然数整除数
* 判断i是否是素数的一个方法是看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()”);
类 B中使用 super 关键字,是为了调用父类的含有一个参数的构造方法
实例化父类对象时,调用父类 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