SCJP考题13

来源:互联网 发布:迭代算法 编辑:程序博客网 时间:2024/05/21 07:05

子类的构造函数会自动调用父类无参数的构造函数

 

在重写中,所谓子类中方法的访问控制不能比父类中方法的访问控制范围窄是指:

Ø       一个package方法可以被重写为packageprotectedpublic

Ø       一个protected方法可以被重写为protectedpublic

Ø       一个public方法只可以被重写为public

局部变量不可以使用任何访问修饰符

局部变量也不可以使用除final以外的任何其它非访问修饰符

任何在局部变量上使用不法修饰符的代码都会得到一个编译错误

abstract不能与final一起使用

abstract不能与private一起使用

abstract不能与synchronized一起使用

abstract不能与native一起使用

abstract不能与strictfp一起使用

abstract不能与static一起使用

最后:abstract不能用于成员变量

 

Which two of the following are legal definitions for non-nested classes and interface?(select two)

A  static public interface Foo()

B  abstract public class Foo()

C  protected interface Foo()

D  final abstract class Foo()

E  final public class Foo()

正确答案:B   E

 

 

Public class MyOuter{

    Public static class MyInner{

        Public static void foo(){}

}

}

正确声明MyInner类:MyOuter.MyInner m=new MyOuter.MyInner()

 

注意: MyInner m=new MyOuter.MyInner()是不对的!!

 

 

 

 

SectionOperators and Assignments

Problem[10]

Which statements are true concerning the

effect of the >> and >>> operators?

[Select All]

[1]For non-negative values of the left

operand, the >> and >>> operators will

have the same effect.

[2]The result of (-1 >> 1) is 0.

[3]The result of (-1 >>> 1) is -1.

[4]The value returned by >>> will never

be negative as long as the value of the

right operand is equal to or greater than

1.

[5]When using the >> operator, the

leftmost bit of the bit representation

of the resulting value will always be the

same bit value as the leftmost bit of the

bit representation of the left operand.

[Correct Choices]

[1] true

[2] false

[3] false

[4] true

[5] true

 

 

 

SectionOverloading Overriding Runtime

Type and Object Orientation

Problem[22]

What will be written to the standard

output when the following program is run?

class Base {

int i;

Base() {

add(1);

}

void add(int v) {

i += v;

}

void print() {

System.out.println(i);

}

}

class Extension extends Base {

Extension() {

add(2);

}

void add(int v) {

i += v*2;

}

}

public class Qd073 {

public static void main(String

args[]) {

bogo(new Extension());

}

static void bogo(Base b) {

b.add(8);

b.print();

}

}

[Select One]

[1]9

[2]18

[3]20

[4]21    ///////////////////

[5]22

[Correct Choice]

5

 

 

 

 

SectionLanguage Fundamentals

Problem[21]

What does the value returned by the

method getID() found in class

java.awt.AWTEvent uniquely identify?

[Select One]

[1]The particular event instance.

[2]The source of the event.

[3]The set of events that were triggered

by the same action.

[4]The type of event.

[5]The type of component from which the

event originated.

[Correct Choice]

4

 

 

SectionDeclarations and Access Control

Problem[23]

Which lines of code are valid

declarations of a native method when

occurring within the declaration of the

following class?

public class Qf575 {

// insert declaration of a native

method here

}

[Select All]

[1]native public void

setTemperature(int kelvin);

[2]private native void

setTemperature(int kelvin);

[3]protected int native

getTemperature();

[4]public abstract native void

setTemperature(int kelvin);

[5]native int setTemperature(int kelvin)

{}

[Correct Choices]

[1] true

[2] true

[3] false

[4] false

[5] false

 

 

SectionOperators and Assignments

Problem[66]

The 8859-1 character code for the uppercase

letter A is 65. Which of these code fragments

declare and initialize a variable of type char

with this value?

[Select All]

[1]char ch = 65;

[2]char ch = '/65';

[3]char ch = '/0041';

[4]char ch = 'A';

[5]char ch = "A";

[Correct Choices]

[1] false

[2] false

[3] false

[4] true

[5] false

 

 

 

 

 

SectionThreads

Problem[63]

Given the following code, which

statements concerning the objects

referenced through the member variables

i, j and k are true, given that any thread

may call the methods a, b and c at any

time?

class Counter {

int v = 0;

synchronized void inc() { v++; }

synchronized void dec() { v--; }

}

public class Q7ed5 {

Counter i;

Counter j;

Counter k;

public synchronized void a() {

i.inc();

System.out.println("a");

i.dec();

}

public synchronized void b() {

i.inc(); j.inc(); k.inc();

System.out.println("b");

i.dec(); j.dec(); k.dec();

}

public void c() {

k.inc();

System.out.println("c");

k.dec();

}

}

[Select All]

[1]i.v is guaranteed always to be 0 or

1.

[2]j.v is guaranteed always to be 0 or

1.

[3]k.v is guaranteed always to be 0 or

1

[4]j.v will always be greater than or

equal to k.v at any give time.

[5]k.v will always be greater than or

equal to j.v at any give time.

[Correct Choices]

[1] true

[2] true

[3] false

[4] false

[5] false

 

 

SectionThe java.io package

Problem[61]

Given that file is a reference to a File

object that represents a directory,

which code fragments will succeed in

obtaining a list of the entries in the

directory?

[Select All]

[1]Vector filelist = ((Directory)

file).getList();

[2]String[] filelist = file.directory();

[3]Enumeration filelist =

file.contents();

[4]String[] filelist = file.list();

[5]Vector filelist = (new

Directory(file)).files();

[Correct Choices]

[1] false

[2] false

[3] false

[4] true

[5] false

 

 

 

SectionLanguage Fundamentals

Problem[58]

Which statements concerning the event

model of the AWT are true?

[Select All]

[1]At most one listener of each type can

be registered with a component.

[2]Mouse motion listeners can be

registered on a List instance.

[3]There exists a class named

ContainerEvent in package

java.awt.event.

[4]There exists a class named

MouseMotionEvent in package

java.awt.event.

[5]There exists a class named

ActionAdapter in package java.awt.event.

[Correct Choices]

[1] false

[2] true

[3] true

[4] false

[5] false

 

 

 

SectionThe java.awt package - Layout

Problem[57]

What will be the appearance of an applet

with the following init() method?

public void init() {

add(new Button("hello"));

}

[Select One]

[1]Nothing appears in the applet.

[2]A button will cover the whole area of

the applet.

[3]A button will appear in the top left

corner of the applet.

[4]A button will appear, centered in the

top region of the applet.

[5]A button will appear in the center of

the applet.

[Correct Choice]

4

 

Problem[55]

Which statements concerning the switch

construct are true?

[Select All]

[1]All switch statements must have a

default label.

[2]There must be exactly one label for

each code segment in a switch statement.

[3]The keyword continue can never occur

within the body of a switch statement.

[4]No case label may follow a default

label within a single switch statement.

[5]A character literal can be used as a

value for a case label.

[Correct Choices]

[1] false

[2] false

[3] false

[4] false

[5] true

 

 

 

Problem[51]

Which statements concerning the methods

notify() and notifyAll() are true?

[Select All]

[1]Instances of class Thread have a

method called notify().

[2]A call to the method notify() will

wake the thread that currently owns the

monitor of the object.

[3]The method notify() is synchronized.

[4]The method notifyAll() is defined in

class Thread.

[5]When there is more than one thread

waiting to obtain the monitor of an

object, there is no way to be sure which

thread will be notified by the notify()

method.

[Correct Choices]

[1] true

[2] false

[3] false

[4] false

[5] true

 

 

 

504. What letters get written to the standard output with the following code?

class Test{

public static void main(String[] args){

try {

method();

} catch(Exception e){}

}

static void method(){

try {

wrench();

System.out.println("a");

} catch (ArithmeticExeption e){

System.out.println("b");

}finally{

System.out.println("c");

}

Syatem.out.println("d");

}

static void wrench(){

throw new NullPointerException();

}

}

Select all valid answer.

A. "a"

B. "b"

C. "c"

D. "d"

E. none of there

正确答案: C

511. What appears in the standard output if the method named problem() in the code below throws an instance of class Exception when the method named trythis() is invoked?

public void trythis(){

try{

System.out.println("1");

problem();

}catch(RuntimeException x){

System.out.println("2");

return;

}catch(Exception x){

System.out.println("3");

return;

}finally{

System.out.println("4");

}

System.out.println("5");

}

Select all valid answers.

A. "1"

B. "2"

C. "3"

D. "4"

E. "5"

正确答案: ACD

 

 

 

 

518. What will be printed out if you attempt to compile and run the following code?

int i=9;

switch(i){

default:

System.out.println("default");

case 0:

System.out.println("zero");

break;

case 1:

System.out.println("one");

case 2:

System.out.println("two");

Select the one right answer.

A. default

B. default, zero

C. error default clause not defined

D. no output displayed

正确答案: B

 

 

 

 

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

public class MySwitch{

public static void main(String argv[]){

MySwitch ms=new MySwitch();

ms.anethod();

}

public void anethod(){

int k=10;

switch(k){

//Put thedefault at the botton, not here

defauly

System.out.println("This is thedefault output");

break;

case 10:

System.out.println("ten");

case 20:

System.out.println("twenty");

break;

}

}

}

Select the one reght answer.

A. None of these options.

B. Compile time error target of switch must be an integral type.

C. Compile and run with output "This is the default output".

D. Compile and run with output "ten  twenty".

正确答案: D

 

 

 

542. Given the following code:

class Test{

public static void main(String args[]){

System.out.println(hai());

}

static int hai(){

try{

return 1;

}

catch(Exception e){

System.out.println("Exception");

}

finally{

System.out.println("Finally");

return  2;

}

}

}

What will be the out put?

A. Compilation Error void main Can't return any value.

B. Prints Exception.

C. Prints Exception Finally.

D. Prints Finally and 1.

E. Prints Finally and 2.

正确答案:E

 

 

 

545. Given the following code:

class Test{

public static void main(String args[]){

try{

//ProtocoIException

}catch(ProtocalException e){

System.out.println("I");

}catch(IOException e){

System.out.println("E");

}finally{

System.out.println("F");

}

}

}

If a ProtocoIException occurs in try block. what will be the output? Select all.

A. I

B. E

C. F

D. Compilation Error says that there is no matching catch block

正确答案:AC

 

529. What is the result when you compile and run the following code?

public class Test{

static void throwMethod(){

System.out.println("Inside throw Method.");

throw new IllegalAccessException("demo");

}

public static void main(String args[]){

try{

throwMethod();

}

catch(IllegallAccessException e){

System.out.Println("Caught"+e);

}

}

}

Select the one right answer.

A. Compilation error

B. Runtime error

C. Compile successfully, nothing is printed

D. Inside throwMethod. followed by caught: java.lang.IllegalAccessExcption:demo

正确答案: A

 

 

 

626. What is the reason using $ in inner class representation?

A. Because the inner classes are defined inside of amy class

B. Due to the reason that inner classes can be defined inside any method

C. This is convention adopted by(被。。。。采用) Sun,to insure(确保) that there is no ambiguity(含糊的) between packages and inner classes.

D. Because if use getClass(),getName() will gives you the error

正确答案:C

 

 

623. What is the result from the following code when you run?

import java,io.*;

calss A {

A()throws Exception{

System.out.println("execrting class A constructor");

throw mew IOException();

}

}

public class B extends A{

B(){

System.out.println("Execrting class B constructor");

}

public static void main(String args[]){

try{

A a=new B();

}catch(Exception c){

System.out.println(c.getMessage());

}

}

}

Select the one right answer.

A. Executing class A constructor

B. Executing class B constructor  

C. Runtime error

D. Compile time error

正确答案:D

 

 

Which three are valid declarations of a float?

A   float f1=054321

B   float f2=314e7

C   float f3=123456789

D   float f4=2.182D

E   float f5=2002.02

F    float f6=1.732F

正确答案:ACF

 

 

 

633. Which of the following statements are true?

A. An anonymous(匿名的) class cannot have any constructors.

B. An anonymous class can only be created within the body of a method.

C. An anontmous class can only access static fields of the enclosing class.

D. An anontmous class instantiated and declared in the same place.

正确答案: AD

 

 

 

646. In the code if you compile as "java hello4.java" following files will be generated.

1  import java applet.Applet;

2  import java.awt*;

3  import java.awt.event.*;

4  public class hello4 extends Applet {

5  public void int(){

6  add(new myButton("BBB"));

7  }

8  public void paint(Graphics screen){

9  }

10 class myButton extends Button{

11 myButton(String label){

12 super(label);

13 }

14 public String paramString(){

15 return srper.parmString();

16 }

17 }

18 public static void main(String[] args){

19 Frame myFrame=new Frame(

20 "hello4");

21 myFrame.setSize(300,100);

22 Applet myApplet=new hello4();

23 Butten b=new Button("My Button");

24 myApplet.add(b);

25 b setLabel(b getLabel()+"New");

26 //myButton b1=new myaButton("PARAMBUTTON");

27 System.out.println(b1.paramString());

28 myFrame.set(myApplet);

29 myFrame.addVisible(true);

30 myFrame.addWindowListener(new WindowAdapter()){

31 public void windowClosing(WindowEvent e){

32 System.exit(0);}});

33}

34 }//End hello4 class.

Select the one reght answer.

A. hello4.class,myButton.class,hello4.lass

B. hello4.class,hello4$myButton.class,hello4$1.class

C. hello4.class.hello4$myButton.class

正确答案:B

 

 

 

 

 

649. What is the output of the following code?

1:  class Test

2:  {

3:  Test(int i)

4:  {

5:  System.out.println("Test("+i+")");

6: }

7: }

8:

9: public class Q12

10:{

11:static Test t1=new Test(1);

12:

13:Test t2=new Test(2);

14:

15:static Test t3=new Test(3);

16:

17:public static void main(String[] args)

18:{

19:Q12Q=new Q12();

20:}

21:}

Select the one right answer.

A. Test(1)

Test(2)

Test(3)

B. Test(3)

Test(2)

Test(1)

C. Test(2)

Test(1)

Test(3)

D. Test(1)

Test(3)

Test(2)

正确答案:D

 

 

648. What will happen if you compile/run the following code?

1: public class Q11

2: {

3: static String str1="main method with String[] args";

4: static String str2="main method with int[] args";

5:

6: public static void main(String[] args)

7: {

8: System.out.println(str1);

9: }

10:

11:public static void main(int[] args)

12:{

13:System.out.println(str2);

14:}

15:}

Select the one right answer.

A. Duplicate(复制) method main(),compilation error at line 6;

B. Duplicate method main(),compilation error at line 11;

C. Prints"main method with main String[]args".

D. Prints"main method with main int[]args".

正确答案:C

652. What is displayed when the following code is executed?

class parent{

private void method1(){

System.out.println("Parent's method1()");

}

public void method2(){

System.out.println("Parent's method2()");

method1();

}

}

class Child extends Parent{

Public void method1(){

System.out.println("Child's method1()");

}

public static void main(String args[]){

Parent p=new Child();

p.method2();

}

}

Select the one right avswer.

A. Compile-time error

B. Run-time error

C. Prints:Patent's method2() Parent's method1()

D. Prints:Patent's method2() Child's method1()

正确答案:C

 

653. What is displayed when the following code is executed?

class Paten{

void method1(){

System.out.println("Parent's method1()");

}

public void method2(){

System.out.println("Parent's method2()");

method1();

}

}

class Child extends Parent{

public void method1(){

System.out.println("Child's method1()");

}

public static void main(String args[]){

Parent p=new Child();

p.method2();

}

}

Select the one right answer.

A. Compile-time error

B. Run-time error

C. Prints:Parent's method2() Parent's method1()

D. Prints:Parent's method2() Child's method1()

正确答案:D

 

 

666. Examine the following class definition:

public class Test{

public static void test(){

print();

}

public static void print(){

System.out.println("Test");

}

public void print(){

System.out.println("Another Test");

}

}

What is the result of compiling this class:

Select the most appropriate answer.

A. A successful compilation.

B. A warning stating that there is a duplicated method.

C. An error stating that there is a duplicated method.

D. An error stating that the method test() will call one or other of the print() methods.

正确答案:C

 

 

679.Given the following code:

    1.class Happy {

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

    3.public class Sad {     不能是public,不写或者是final

    4.public void methodA() {

    5.System.out.println("inside sad");

    6.}

    7.}

    8.System.out.println("inside happy");

    9.}

    10.}

What will be the output?

A. compilation error at line no.3

B. compilation error at no.4

C. compilation error at line no.5

D.compilation succeeds but runtime exeption

E.clean compile and give the output "inside happy"

正确答案 A

 

 

525. The thread run() method has the following code, what is the result when the thread runs?

try{

sleep(200); 不会扔出一个IOException

System.out.println("Printing from thread run()method");

}catch(IOException ie){}

Selet the one right answer.

A. Compile time error

B. Prints on the console Printing from thread run() method

C. At line 2 the thread will be stop running and resumes after 200 milliseconds and prints Printing from thread run() method

D. At line 2 the thread will be stop running and resumes exactly 200 milliseconds elapsed

正确答案: A

 

 

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

public class Test{

static public int i=10;

public static void main(String argv[]){

switch(i){

default:

System.out.println("no value given");

case 1:

System.out.println("one");

case 10:

System.out.println("ten");

case 5:

System.out.println("five");

}

}

}

正确答案:ten  five

 

如果i=6   输出:no value given   one   ten  five

 

 

 

 

 

10.What output is produced by the following program?

class Test{

public static void main(String args[]){

long size=10;

int[]array=new int[size];

size=20;

System.out.println(array.length);

}

}

Select the one right answer.

A. A compiler error.

B. A runtime error.

C. 10

D. 20

正确答案:A

 

 

28. What output is produced by the following program? Note that the main() method is not declared public.

class Test{

static void main(String args[]){

System.out.println("OK");

}

}

Select the one right answer.

A. A compiler error.

B. A runtime error.

C. OK

正确答案: C

 

 

29. What output is produced by the following program? Note that the main() method is not declared static.

class Test{

public void main(String args[]){

System.out.println("OK");

}

}

Select the one right answer.

A. A compiler error.

B. A runtime error.

C. OK

正确答案: B

 

33. True or false? In Java primitives(原始的) are passed by value and objects are passed by reference.                   数组

Fill in the blank.

正确答案: False

 

 

2.what is the numerical range of a char ?(choose one)

 A -128 to 127

 B –(2^15)to(2^15)-1

 C 0 to 32767

 D platform dependent

 E 0 to 65535

 

正确答案:E

 

 

 

4. which two of the following are legal declarations for nonnested (非嵌套)class and interface (choose two)

A final abstract class test{}  final abstract 不能同时用在一个类中

B public static interface test{}  接口和类不能声明为static

C final public class test{}

D protected abstract class test{}

E protected interface test{}   protected 不能标识类和接口

F abstract public class test{}

 

正确答案C   E

 

 

5How many of the following are legal method declarations?

A  protected abstract void m1();

B  static final void m1(){}

C  transient private native void m1(){}  transient 只适用于变量声明,而不适用于类和方法声明。

D  synchronized public final void m1(){}

E  private native void m1();

F  static final synchronized protected void m1(){}

正确答案A  B  D   E   F

 

6.which two are valid declarations within an interface?(choose two)

A  public static short stop=23;

B  protected short stop=23;

C  transient short stop=23;

D  final void madness(short stop);

E  public Boolean madness(long bow);

F  static char madness(double duty);

接口不能是protected, transient,final , static

 

正确答案A  E

7Which three are valid method signatures in an interface?(choose three)

A  private int get Area();  接口方法必须是public或不写

B  public float getVol(float x);

C  public void main(String[] args);

D  public static void main(String[] args); 去了static就行了

E  Boolean setFlag(Boolean [] test[]);

正确答案:B  C   E

 

 

 

4. which two of the following are legal declarations for nonnested (非嵌套)class and interface (choose two)

A final abstract class test{}  final abstract 不能同时用在一个类中

B public static interface test{}  接口和类不能声明为static

C final public class test{}

D protected abstract class test{}

E protected interface test{}   protected 不能标识类和接口

F abstract public class test{}

 

C

E

 

 

 

241. What output is produced by the following program?

class Test{

public static void main(String args[]){

System.out.println(Double.isNaN(3.0%0));

System.out.print("");

System.out.println(Double.isNaN(3.0/0));

}

}

Select of the right answers.

A. false false

B. false ture

C. ture false

D. true true

正确答案:C

 

242. What output is produced by the following program?

class Test{

public static void main(String args[]){

try{

double x=64.0;

double y=0.0;

System.out.println(x%y==x%y);

}cateh(Exception e){

System.out.println("Exception");

}

}

}

Select all of the right answers from the flowing

A. A compiler error

B. Exception

C. true

D. fatse

正确答案:D

 

 

 

243. What output is produced by the following program?

class Test{

public static void main(String args[]){

try{

System.out.println(Float.NaN==Float NaN);

System.out.println(""+

(Float.POSITIVE.INFINITY==Float.POSITIVE_INFINITY));

}catch(Exception e){

System.out.println("Exception");

}

}

}

Select all of the right answers

A. A compiler error

B. Exception

C. true true

D. fatse false

正确答案:D

 

 

 

 

 

Public class TestThread extends Thread{

       Public static void main(String[] args){

              TestThread t=new TestThread();

              t.run();

}

Public void run(){

       For(int i=1;i<4;i++){

       System.out.println(i+”  ”);

}

}

}

 

输出答案是:1  2  3

Which two are true about a non-static method-local inner class(select two)?

A it cannot implement an interface

B  it can be marked abstract

C  it can be marked static

D  it must be marked final

E  it can access all members of the enclosing class

正确答案:B  E

 

 

 

Public class wrap {

       Public static void main(String[] args){

              String s=”343”;

              //insert code here

}

 

}

Which three lines inseted independently at line 4 will cause complier errors?

A  long f1 =Long.longValue(S);

B  long f2 = Long.valueOf(s);

C  long f3 = new Long(343).longValue();

D  long f4 = Long.parseLong(343);

E  long f5 = Long.valueOf(s).longValue();

正确答案:A  B  D

 

 

 

247. What output is produced by the following program?

class Test{

public static void main(String args[]){

try{

int x=-7;

System.out.println(x/2+""+(x>>1));

}catch(Exception e){

System.out.println("Exception");

}

}

}

Select all of the right answers from the flowing.

A. A compiler error

B. Exception

C. -3 -3

D. -3 -4

E. -4 -4

F. None of the above

正确答案: D

 

 

 

Given the flowing:

Public class Test{

       Public static void main(String[] args){

              Int[ ][ ][ ] x=new int [3][ ][ ];

              Int I,j;

              X[0]=new int[4][ ];

              X[1]=new int[2][ ];

              X[2]=new int[5][ ];

              For(i=0;i<[i].length;j++){

                     For(j=0;j<x[i].length;j++){

                            X[i][j]=new int[i+j+1]

                            System.out.println(“Size=”+x[i][j].length);

}

}

}

}

How many lines of output will be producted?(choose one)

A 7

B 9

C  11

D   13

E  compilation fails

F  an exception is thrown at runtime

 

C

 

 

712. There are 20 threads are waiting in the waiting pool with same priority. how can you invokes 15th thread from the wailing pool?

A. By calling resume() method

B. By calling interrupt() method

C. Calling call() method

D. By calling notify(15)method on the thread instance

E. None of the above

怎么调用!!是不知道么???

 

 

721. What happens when you try to compile and run the following application?

public class Test{

public static void main(String[] args){

new Test();

}

Test(){

Test alias1=this;

Test alias2=this;

synchronized(alias1){

try{

slias2.wait();

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

}

Catch(InterruptedException e){

System.out.println("INTERR UPTED");

}

catch(Exception e){

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

}

finally{

System.out.println("FINALLY");

}

}

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

}

}

Choose all correct options.

A. The application compiles but doesn't print anything.

B. The application compiles and print"DONE WAITING"

C. The application compiles and print "FINALLY"

D. The application compiles and print "ALL DONE"

E. The application compiles and print "INTERRUPTED"

正确答案: A

 

 

 

726. What is the result of compiling and executing the following Java class:

public class Test extends Thread{

public void run(){

System.out.println("In run");

suspend();

resume();

System.out.println("Leaving run");

}

public static void main(Syring args[]){

(new Test()).start();

}

}

Select the most appropriate answer.

A. Compilation will fail in the method main.

B. Compilation will fail in the method run.

C. A warning will be generated for method run.

D. The string" In run" will be printed to standard out.

E. Both strings will be printed tp standard out.

F. Nothing will happen.

正确答案: D

我觉得是E

 

 

687. What appears in the standard output when you run the Dots class?

class Test impltements Runnable{

DotThread t;

public static void main(String[]args){

Test d=new Test();

d.t=new DotTgread();

}

public void init(){

t.start();

t=new DashThread().start();

}

}

class DotThread extends Thread{

public void run(){

for(int index=0;index<100;index++)

System.out.print(".");

}

}

class DashThread extends Thread{

public void run(){

for(int index=0;index<100;index++)

System.out.print("-");

}

}

Select the one right answer.

A. nothing

B. 100 dots(.)

C. 200 dots(.)

D. 100 dashes(-)

E. 100 dots(.)and 100 dashes(-)

 

 

 

 

 

 

Which of the following Collections classes can return object references in the order they were added?(choose one)

A  java.util.Collection

B  java.util.Hashtable

C  java.util.Map

D  java.util.Vector

正确答案:D

 

 

What kind of Stream is the Stream is the System.out.object??(choose one)

A  java.io.printStream

B  java.io.TerminalStream

C  java.io.FileWriter

D  java.io.SystemStream

正确答案:A

 

 

Which of the following events has a matching  adapter class that implements the appropriate listener interface?(choose two)

A  java.awt.event.FocusEvent

B  java.awt.event.KeyEvent

C  java.awt.event.ItemEvent

D  java.awt.event.ActionEvent

正确答案:A  B

 

 

Which of the following are methods of the Collection interface?

A  isEmpty()

B  getIndex();

C  iterator()

D  toArray()

E  isFull()

 正确答案:A  C  D

 

Which of the following AWT components can generate an ActionEvent?(choose one)

A  java.awt.List

B  java.awt.Canvas

C  java.awt.Panel

D  java.awt.Scrollbar

正确答案:A 

 

 

Which of the following will print “NULL” when the object reference tmp has the null value?(choose one)

A   if(temp==null) System.out.println(“NULL”);

B  if(temp=null) System.out.println(“NULL”);

C  if(temp.equal(null)) System.out.println(“NULL”);

D  if(x instanceof null) System.out.println(“NULL”);

正确答案: A

 

 
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 仓单交割 什么是交割单 股票交割单 交割单 五十岁用什么牌子护肤品好 适合30岁女人用的护肤品 五十岁护肤品 三十五岁女人用什么护肤品好 五十岁用什么护肤品好 适合50岁女人用的护肤品 什么牌子护肤品适合30岁女人 三十岁女人用什么护肤品好 五十岁的女人用什么护肤品 三十岁的女人用什么护肤品好 女人用什么护肤品好 中年女人用什么护肤品 中年女性护肤品推荐 五十岁用什么牌子护肤品 女人用什么化妆品对皮肤好 四十女人用什么护肤品好 女人用什么洗发水好 适合30岁女人用的平价护肤品 20多岁的女人用什么护肤品好 适合40岁女人用的护肤品 四十岁女人适合什么护肤品 30岁的女人适合用什么护肤品 适合30岁女性的护肤品 40多岁的女人用什么护肤品 五十岁适合什么化妆品 适合50岁女性的护肤品 适合30岁女性护肤品 四十岁的女人适合什么护肤品 适合40岁女人的化妆品 女人用什么化妆品好 四十岁的女人适合什么化妆品 年轻女性护肤品 适合40岁女性的护肤品 30岁女人用什么护肤品 30多岁的女人用什么护肤品 女人不用护肤品可以吗 适合五十岁女人的化妆品