202 Sun SATC Java程序员(全真卷02)

更新时间:2023-09-26 00:49:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

SUN SATC Java程序员培训全真卷02

全真题02

1:单选(1分)在子类中调用父类中被覆盖的方法时需要使用哪项关键字? A this B super C new D 以上都不是 2:单选(1分)

public class Employee{ private String name;

public Employee(String name){

this.name = name; }

public String getName(){

return name; } }

public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } }

执行语句new Manager(“smith”)后程序的输出是哪项? A smith B null C 编译错误 D name 3:单选(1分)

public class Employee{ private String name;

public Employee(String name){

this.name = name; }

public void display(){ System.out.print(name); } }

public class Manager extends Employee{ private String department;

public Manager(String name,String department){ super(name);

this.department = department; }

public void display(){

System.out.println(super.display()+”,”+department); } }

执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项? A smith,SALES B null,SALES C smith,null D null,null

1/14

SUN SATC Java程序员培训全真卷02

4:单选(1分)用于编译Java源文件的JDK工具是? A javac B jdb C java D junit 5:单选(1分)现有: 1. class Beverage {

2. Beverage() { System.out.print(\); } 3. }

4. class Beer extends Beverage {

5. public static void main(String [] args) { 6. Beer b = new Beer(14); 7. }

8. public int Beer(int x) { 9. this();

10. System.out.print(\); 11. }

12. public Beer() { System.out.print(\); } 13. }

结果是什么? A beer1 beverage B beer2 beverage C beverage beer1 D 编译失败 6:单选(1分)Java程序的跨平台特征是由以下哪项技术实现的? A 系统硬件 B JVM C Java编译器 D 操作系统 7:单选(1分)现有: 1. class Over {

2. int doIt(long x) { return 3; } 3. } 4.

5. class Under extends Over { 6. // insert code here 7. }

和四个方法:

short doIt(int y) { return 4; }

int doIt(long x, long y) { return 4; } private int doIt(short y) { return 4; } protected int doIt(long x) { return 4; }

分别插入到第6行,有几个可以通过编译? A 0 B 1 C 3 D 4 8:单选(1分)现有: 5. class BitStuff {

6. BitStuff go() { System.out.print(\); return this; } 7.}

8. class MoreBits extends BitStuff {

9. MoreBits go() { System.out.print(\); return this; } 10.

11. public static void main(String [] args) { 12. BitStuff [] bs = {new BitStuff(), new MoreBits()};

2/14

SUN SATC Java程序员培训全真卷02

13. for( BitStuff b : bs) 14. b.go(); 15. } 16.} 结果为: A bits bits B bits more C more more D 编译失败 9:单选(1分)下列有关接口的叙述错误的是哪项? A 接口中只能包含抽象方法和常量 B 一个类可以实现多个接口 C 接口不能被继承 D 类实现接口时必须实现其中的方法 10:单选(1分)现有两个文件 1. package x;

2. public class X {

3. public static void doX() { System.out.print(\); } 4.} 和:

1. import x.X; 2. class Find {

3. public static void main(String [] args) { 4. X myX = new X(); myX.doX(); 5. X.doX(); 6. x.X.doX();

7. x.X myX2 = new x.X(); myX2.doX(); 8. } 9. } 结果为:

A doX doX doX doX B Find类中出现多个错误,编译失败。

C Find类第 4行出现一个错误,编译失败。 D Find类第 5 行出现一个错误,编译失败。 11:单选(1分)现有: 1. interface Animal { 2. void eat(); 3. } 4.

5. // insert code here 6.

7. public class HouseCat extends Feline { 8. public void eat() { } 9. }

和五个声明:

abstract class Feline implements Animal { }

abstract class Feline implements Animal { void eat(); }

abstract class Feline implements Animal { public void eat(); } abstract class Feline implements Animal { public void eat() { } } abstract class Feline implements Animal { abstract public void eat(); } 分别插入到第5行,有几个可以通过编译?

3/14

SUN SATC Java程序员培训全真卷02

A 0 B 1 C 2 D 3 12:单选(1分)现有: 2. class Mineral {

3. static String shiny() { return \ 4. }

5. class Granite extends Mineral {

6. public static void main(String [] args) { 7. String s = shiny() + getShiny(); 8. s = s + super.shiny(); 9. System.out.println(s); 10. }

11. static String getShiny() { return shiny(); } 12. } 结果为: A 3 B 12 C 111 D 编译失败 13:单选(1分)现有: 1. class Bird {

2. static void talk() { System.out.print(\); } 3. }

4. class Parrot extends Bird {

5. static void talk() { System.out.print(\); } 6. public static void main(String [] args) { 7. Bird [] birds = {new Bird(), new Parrot()}; 8. for( Bird b : birds) 9. b.talk(); 10. } 11.} 结果为: A chirp chirp B chirp hello C hello hello D 编译失败 14:单选(1分)现有:

1. interface I { void go(); } 2.

3. abstract class A implements I { } 4.

5. class C extends A { 6. void go(){ } 7. }

结果是什么? A 代码通过编译 B 由于多个错误导致编译失败 C 由于第1行的错误导致编译失败 D 由于第6行的错误导致编译失败 15:单选(1分)所有异常的父类是哪项? A Exception B Error C RuntimeException D Throwable 16:单选(1分)

public class TestApp{

4/14

SUN SATC Java程序员培训全真卷02

public static void main(String[] args){

try{

int i = 0; int j = 1 / i;

System.out.println(“1”); }catch(Exception e){ System.out.print(“3”); }finally{

System.out.print(“4”); } } }

上述程序运行后的输出是哪项? A 4 B 34 C 43 D 14

17:单选(1分)在方法的声明中,要求该方法必须抛出异常时使用哪个关键字? A throws B catch C finally D throw 18:单选(1分)现有:

1. class Parser extends Utils {

2. public static void main(String [] args) {

3. try { System.out.print(new Parser().getInt(\)); 4. } catch (Exception e) { 5. System.out.println(\); } 6. }

7. int getInt(String arg) throws Exception { 8. return Integer.parseInt(arg); 9. } 10.}

11. class Utils {

12. int getInt(String arg) { return 42; } 13.} 结果为: A 42 B Exc C 42Exc D 编译失败 19:单选(1分)现有: 1. class Number {

2. public static void main(String [] args) { 3. try {

4. System.out.print(Integer.parseInt(\)); 5. } catch (RuntimeException r) { 6. System.out.print(\);

7. } catch (NumberFormatException e) { 8. System.out.print(\); 9. } 10. } 11. }

5/14

本文来源:https://www.bwwdw.com/article/omld.html

Top