SCJP在线测试
时间还剩:
联系我们   收藏本站   设为首页   
 
JAVA下载 JAVA文摘 J2me学习 JAVA实例              


SCJP在线测试

〖 姓名:Guest〗

第1题(id号=209):

Given the following declaration
  String s = "hello";
  Which are legal code?
A. s >> = 2;
B. char c = s[3];
C. s += "there";
D. int i = s.length();
E. s = s + 3;


请选择: A B C D E

第2题(id号=469):

What is the requirement of the class which implements the following Interface
 public interface Test {
   void someMethod();
 }
Select all correct answers
a. Should have someMethod which must be necessarily declared as public.
b. Should have someMethod which could be "friendly" or public
c. Should have someMethod which should not throw any checked exceptions.
d. Should have someMethod which cannot be sychronized as 
   sychronized is not in the signature of the interface definition.


请选择: A B C D

第3题(id号=131):

 public class Test{ 
   public static void stringReplace(String text){ 
     text=text.replace('j','l'); 
    } 
    public static void bufferReplace(StringBuffer text){ 
      text=text.append("c"); 
     } 
   public static void main(String args[]){   
     String textString=new String("java"); 
     StringBuffer textBuffer=new StringBuffer("java"); 
      StringReplace(textString); 
      bufferReplace(textBuffer); 
    System.out.println(textString+textBuffer); 
      } 
      } 
   what is the output? 
  A. lavajavac
  B. javajavac


请选择: A B

第4题(id号=221):

Which are correct class declarations? Assume in each case textconstitutes the entire 
contents of a file called Fred.java on a system with a case-significant system.
A. public class Fred {
    public int x = 0;
    public Fred (int x) {
     this.x = x;
    }
  }
B. public class fred {
     public int x = 0;
     public fred (int x) {
      this.x = x;
     }
   }
C. public class Fred extends MyBaseClass, MyOtherBaseClass {
     public int x = 0;
     public Fred (int xval) {
      x = xval;
     }
  }
D. protected class Fred {
     private int x = 0;
     private Fred (int xval) {
     x = xval;
     }
   }
E. import java.awt.*;
    public class Fred extends Object {
      int x;
      private Fred (int xval) {
        x = xval;
     }
   }


请选择: A B C D E

第5题(id号=80):

The following code is entire contents of a file called Example.java,causes
precisely one error during compilation: 

1) class SubClass extends BaseClass{ 
2) } 

3) class BaseClass(){ 
4) String str; 
5) public BaseClass(){ 
6) System.out.println(“ok”);} 
7) public BaseClass(String s){ 
8) str=s;}} 
9) public class Example{ 
10) public void method(){ 
11) SubClass s=new SubClass(“hello”); 
12) BaseClass b=new BaseClass(“world”); 
13) } 
14) } 

Which line would be cause the error? 
A. 9 B. 10 C. 11 D.12 


请选择: A B C D

第6题(id号=641):

Given:

class Knowing {
  static final long tooth = 343L;
  static long doIt(long tooth) {
    System.out.print(++tooth + " ");

    return ++tooth;
  }
  public static void main(String[] args) {
    System.out.print(tooth + " ");
    final long tooth = 340L;
    new Knowing().doIt(tooth);
    System.out.println(tooth);
  }
}

What is the result?

A. 343 340 340 

B. 343 340 342 

C. 343 341 342 

D. 343 341 340 

E. 343 341 343 

F. Compilation fails.

G. An exception is thrown at runtime.


请选择: A B C D E F G

第7题(id号=388):

Consider the following code: What will be printed?
public class charTest2{
  public static void main(String[] args){
   int y = 020;
   char b = 'u0010'
   if(b==y)
     System.out.println("Char 'u0010' = 16.0");
  }
}
A. Nothing will be printed.
B. Compilation error. The char variable cannot be assigned this way.
C. Char 'u0010' = 16.0
D. Compilation error. The int variable cannot be assigned this way.
E. Compilation error. The char variable cannot be assigned this way.


请选择: A B C D E

第8题(id号=47):

public class Parent {
  public int addValue( int a, int b) {
  int s;
  s = a+b;
  return s;
  }
  }
  class Child extends Parent {
  }
  Which methods can be added into class Child?
  A. int addValue( int a, int b ){// do something...}
  B. public void addValue (){// do something...}
  C. public int addValue( int a ){// do something...}
  D. public int addValue( int a, int b )throws MyException {//do something...}


请选择: A B C D

第9题(id号=643):

Given:

1. class Eco {
2.   public static void main(String[] args)    {
3.     Eco e1 = new Eco();
4.     Eco e2 = new Eco();
5.     Eco e3 = new Eco();
6.     e3.e = e2;
7.     e1.e = e3;
8.     e2 = null;
9.     e3 = null;
10.    e2.e = el;
11.    e1   =  null;
12.  }
13.  Eco e;
14. }

At what point is only a single object eligible for GC?

A. After line 8 runs.

B. After line 9 runs.

C. After line 10 runs.

D. After line 11 runs.

E. Compilation fails.

F. Never in this program.

G. An exception is thrown at runtime.


请选择: A B C D E F G

第10题(id号=232):

Given a TextField that is constructed like this:
TextField t = new TextField(30);
Which statement is true?
A. The displayed width is 30 columns.
B. The displayed string can use multiple fonts.
C. The user will be able to edit the character string.
D. The displayed line will show exactly thirty characters.
E. The maximum number of characters in a line will be thirty.


请选择: A B C D E

第11题(id号=156):

 which two interfaces provide the capability to store objects using a key-value pair? 
  A. java.util.Map 
  B. java.util.Set 
  C. java.util.List 
  D. java.util.SortedSet 
  E. java.util.SortedMap 
  F. java.util.Collection 


请选择: A B C D E F

第12题(id号=180):

 which constructs a DataOutputStream ? 
  A.new DataOutputStream("out.txt"); 
  B.new DataOutputStream(new File("out.txt")); 
  C.new DataOutputStream(new Writer("out.txt")); 
  D.new DataOutputStream(new OutputStream("out.txt")); 
  E.new DataOutputStream(new FileWriter("out.txt")); 
  F.new DataOutputStream(new FileOutputSream("out.txt")); 


请选择: A B C D E F

第13题(id号=56):

The variable "result" is boolean. Which expressions are legal?
A. result = true;
B. if ( result ) { // do something... }
C. if ( result!= 0 ) { // so something... }
D. result = 1


请选择: A B C D

第14题(id号=66):

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

class Base 
{
    int i = 99;
    public void amethod()
    {
        System.out.println("Base.amethod()");
    }
        
    Base()
    {
        amethod();
    }
}
public class Derived extends Base
{
    int i = -1;
        
    public static void main(String argv[])
    {
        Base b = new Derived();
        System.out.println(b.i);
        b.amethod();
    }

    public void amethod()
    {
        System.out.println("Derived.amethod()");
    }
}

 A. Derived.amethod()
    -1
    Derived.amethod()

 B. Derived.amethod()
    99
    Derived.amethod()

C. 99
    Derived.amethod()
D.
    Compile time error


请选择: A B C D

第15题(id号=701):

Given:

public class Foo {
   Foo() {System.out.print("foo");}
   class Bar{
      Bar() {System.out.print("bar");}
      public void go() {System.out.print("hi");}
   }
   public static void main(String[] args) {
      Foo f = new Foo ();
      f.makeBar();
   }
   void makeBar() {
     (new Bar() {}).go();
   }
}

What is the result?

A. Compilation fails.

B. An error occurs at runtime.

C. foobarhi 

D. barhi 

E. hi 

F. foohi 


请选择: A B C D E F

第16题(id号=248):

Given the following code, what is the output when a exception other
than a NullPointerException is thrown?
try{
  //some code
}catch(NullPointerException e) {
  System.out.println("thrown 1");
}finally {
  System.out.println("thrown 2");
}
System.out.println("thrown 3");
A thrown 1
B thrown 2
C thrown 3
D none


请选择: A B C D

第17题(id号=616):

Given:

1. class Voop {
2.   public static void main(String [] args) {
3.     doStuff(1);
4.     doStuff(1, 2);
5.   }
6.   // insert code here
7. }

Which, inserted independently at line 6, will compile? (Choose all that apply.)

A. static void doStuff(int... doArgs) { } 

B. static void doStuff (int [] doArgs) { } 

C. static void doStuff(int doArgs...) { } 

D. static void doStuff(int... doArgs, int y) { } 

E. static void doStuff(int x, int... doArgs) { } 


请选择: A B C D E

第18题(id号=76):

Give the following method: 
public void example(){ 
 try{ 
   unsafe(); 
   System.out.println(“Test1”); 
 }catch(SafeException e){System.out.println(“Test 2”); 
 }finally{System.out.println(“Test 3”);} 
 System.out.println(“Test 4”); }

Which will display if method unsafe () run normally? 
A. Test 1 
B. Test 2 
C. Test 3 
D. Test 4 


请选择: A B C D

第19题(id号=346):

Which of the following correctly illustrate how an InputStreamReader can be created:
A. new InputStreamReader(new FileInputStream("data"));
B. new InputStreamReader(new FileReader("data"));
C. new InputStreamReader(new BufferedReader("data"));
D. new InputStreamReader("data");
E. new InputStreamReader(System.in);
Select all correct answers.


请选择: A B C D E

第20题(id号=251):

What happens when you run the following program with the command:
java Prog cat dog mouse
public class Prog {
 public static void main(String args[]) {
   System.out.println(args[0]) ;
}
A. Error at compile time. ArrayIndexOutOfBoundsException thrown
B. Compile with no output
C. Compile and output of dog
D. Compile and output of cat
E. Compile and output of mouse


请选择: A B C D E

第21题(id号=265):

What can you put where the X is?

Public class A{}
A. import java.awt.*;
B. package bla.bla;
C. class bla{}
D. public abstract final method();
E. public final int x = 1000;


请选择: A B C D E

第22题(id号=186):

 AnInterface is an interface 
  AnAdapter0 is a non-abstract,non-final class with a zero argument constructer 
  AnAdapter1 is a non-abstract,non-final class without a zero 
  argument constructer,but with a constructer that takes one int argument 
  which two create an anoymous inner class? 
  A.AnAdapter0 aa=new AnAdapter0(){} 
  B.AnAdapter1 aa=new AnAdapter1(5){} 
  C.AnAdapter1 aa=new AnAdapter1(){} 
  D.AnAdapter0 aa=new AnAdapter0(5){}     
  E.AnInterface ai=new AnInterface(5){} 


请选择: A B C D E

第23题(id号=247):

What is the output of the following code?
outer: for(int i=1; i<3; i++){
   inner: for(int j=1; j<3; j++){
    if (j==2){
       continue outer;
    }
     System.out.println(i " and " j);
   }

}
A. 1 and 1
B. 1 and 2
C. 2 and 1
D. 2 and 2
E. 2 and 3
F. 3 and 2


请选择: A B C D E F

第24题(id号=5):

Which two statements are true for the class java.util.TreeSet? (Choose two) 
  
  A. The elements in the collection are ordered. 
  B. The collection is guaranteed to be immutable. 
  C. The elements in the collection are guaranteed to be unique. 

  D. The elements in the collection are accessed using a unique key. 
  E. The elements in the collection are guaranteed to be synchronized 
 


请选择: A B C D E

第25题(id号=477):

Given the following code fragment.
 switch( x ) {
   case 100:
     System.out.println("One hundred");
     break;
   case 200:
     System.out.println("Two hundred");
     break;
   case 300:
     System.out.println("Three hundred");
     break;
 }
Choose all of the declarations of x that will not cause a compiler error.
a. byte x = 100;
b. short x = 200;
c. int x = 300;
d. long x = 400;


请选择: A B C D

第26题(id号=567):

1. public class MyThread implements Runnable {
2. private String holdA = "This is ";
3. private int[] holdB = {1,2,3,4,5,6,7,8,9,10};
4.
5. public static void main(String args[]) {
6. MyThread z = new MyThread();
7. (new Thread(z)).start();
8. (new Thread(z)).start();
9. }
10.
11. public synchronized void run() {
12. for(int w = 0;w < 10;w++) {
13. System.out.println(holdA + holdB[w] +".");
14. }
15. }
16. }
What is the result?
A Compilation fails because of an error on line 6.
B Compilation fails because of an error on line 11.
C Compilation fails because of errors on lines 7 and 8.
D Compilation succeeds and the program prints each value in the holdB 
  array at the end of the "This is" line. Each value is printed two
  times before the program ends, and the values are not printed in sequential order.
E Compilation succeeds and the program prints each value in the holdB array at
  the end of the "This is" line. Each value is printed in order from 1 to 10, and
  after the value 10 prints, it starts printing the values 1 to 10 in order again.


请选择: A B C D E

第27题(id号=645):

Given:

class Bird {
  { System.out.print("bl "); }
  public Bird() { System.out.print("b2 "); }
}

class Raptor extends Bird {
  static { System.out.print("r1 "); }

  public Raptor() { System.out.print("r2 "); }
  { System.out.print("r3 "); }
  static { System.out.print("r4 "); }
}

class Hawk extends Raptor {
  public static void main(String[] args) {
    System.out.print("pre ");
    new Hawk();
    System.out.println("hawk ");
  }
}

 What is the result?

A. pre b1 b2 r3 r2 hawk 

B. pre b2 b1 r2 r3 hawk 

C. pre b2 b1 r2 r3 hawk r1 r4 

D. r1 r4 pre b1 b2 r3 r2 hawk 

E. r1 r4 pre b2 b1 r2 r3 hawk 

F. Compilation fails.


请选择: A B C D E F

第28题(id号=295):

Consider the following code sample:
class Tree{}
class Pine extends Tree{}
class Oak extends Tree{}
public class Forest {
  public static void main (String [] args){
   Tree tree = new Pine():
   if( tree instanceof Pine )
     System.out.println ("Pine");
   if( tree instanceof Tree )
     System.out.println ("Tree");
   if( tree instanceof Oak )
     System.out.println ( "Oak" );
   else
     System.out.println ("Oops ");
  }
}
Select all choices that will be printed:
A. Pine
B. Tree
C. Forest
D. Oops
E. Nothing will be printed


请选择: A B C D E

第29题(id号=590):

What is the result of attempting to compile and run the following class?
class Ar {
 public static void main(String[] args){
  int[] seeds = new int[3];
  for (int i = 0; i < seeds.length; i++)
    System.out.println(i); 
 }
}
Select all valid answers.
a) 0
b) 1
c) 2
d) 3
e) the program does not compile because the seeds array is not initialized


请选择: A B C D E

第30题(id号=62):

What results from attempting to compile and run the following code?

public class Ternary
{
    public static void main(String args[])
    {
        int a = 5;
        System.out.println("Value is - " + ((a < 5) ? 9.9 : 9));
    }
}

A. prints: Value is - 9
B. prints: Value is - 5
C. Compilation error
D. None of these


请选择: A B C D

第31题(id号=655):

Given the following code:

public class OrtegorumFunction {
  public int computeDiscontinuous(int x) {
    int r = 1;
    r += x;
    if ((x > 4) && (x < 10)) {
      r += 2 * x;
    } else (x <= 4) {
      r += 3 * x;
    } else {
      r += 4 * x;
    }
    r += 5 * x;
    return r;
  }

  public static void main(String [] args) {
    OrtegorumFunction o = new OrtegorumFunction();
    System.out.println("OF(11) is: " + o.computeDiscontinuous (11));
  }
}

What is the result?

A. OF(11) is: 45 

B. OF(11) is: 56 

C. OF(11) is: 89 

D. OF(11) is: 111 

E. Compilation fails.

F. An exception is thrown at runtime.


请选择: A B C D E F

第32题(id号=691):

Given that String implements java.lang.CharSequcnce, and:

import java.util.* ;
public class LongWordFinder {
    public static void main(String [] args) {
        String[] array = { "123", "12345678", "1", "12", "1234567890"};
        List<String> list = Arrays.asList(array);
        Collection<String> resultList = getLongWords(list);
    }
    // INSERT DECLARATION HERE
    {
        Collection<E> longWords = new ArrayList<E>();
        for (E word : coll)
            if (word.length() > 6) longWords.add(word);
        return longWords;
    }
}

Which declarations could be inserted at
 // INSERT DECLARATION HERE so that the program will compile and run? 
(Choose all that apply.)

A. public static <E extends CharSequence> Collection<? extends CharSequence> 
   getLongWords(Collection<E> coll) 

B. public static <E extends CharSequence> List<E> getLongWords(Collection<E> coll) 

C. public static Collection<E extends CharSequence> getLongWords(Collection<E> coll) 

D. public static List<CharSequence> getLongWords(Collection<CharSequence> coll) 

E. public static List<? extends CharSequence> getLongWords(Collection<? extends CharSequence> coll) 

F. static public <E extends CharSequence> Collection<E> getLongWords(Collection<E> coll) 

G. static public <E super CharSequence> Collection<E> getLongWords(Collection<E> coll) 


请选择: A B C D E F G

第33题(id号=359):

Carefully examine the following code:
public class StaticTest {
 static {
  System.out.println("Hi there");
 }
 public void print() {
  System.out.println("Hello");
 }
public static void main(String args []) {
  StaticTest st1 = new StaticTest();
  st1.print();
  StaticTest st2 = new StaticTest();
  st2.print();
} }
When will the string "Hi there" be printed?
A. Never.
B. Each time a new instance is created.
C. Once when the class is first loaded into the Java virtual machine.
D. Only when the static method is called explicitly.
Select the most appropriate answer.


请选择: A B C D

第34题(id号=654):

class Sixties {
  public static void main(String[] args) {
    int x = 5;  int y = 7 ;
    System.out.print(((y * 2) % x));
    System.out.print(" " + (y % x));
  }
}

What is the result?

A. 1 1 

B. 1 2 

C. 2 1 

D. 2 2 

E. 4 1 

F. 4 2 

G. Compilation fails.


请选择: A B C D E F G

第35题(id号=531):

What will be written to the standard output when the following program is run? 

public class Q03e4 { 
 public static void main(String args[]) { 
   String space = " "; 
   String composite = space + "hello" + space + space; 
   composite.concat("world"); 
   String trimmed = composite.trim(); 
   System.out.println(trimmed.length()); 
  } 


A) 5 
B) 6 
C) 7 
D) 12 
E) 13 


请选择: A B C D E

第36题(id号=55):

Given the following code:
  1) class Parent {
  2} private String name;
  3} public Parent(){}
  4} }
  5) public class Child extends Parent {
  6} private String department;
  7} public Child() {}
  8} public String getValue(){ return name; }
  9) public static void main(String arg[]) {
  10} Parent p = new Parent();
  11} }
  12) }
  Which line will cause error?
  A. line 3
  B. line 6
  C. line 7
  D. line 8
  E. line 10


请选择: A B C D E

第37题(id号=323):

Which of the following are acceptable to the Java compiler:
A. if (2 == 3) System.out.println("Hi");
B. if (2 = 3) System.out.println("Hi");
C. if (true) System.out.println("Hi");
D. if (2 != 3) System.out.println("Hi");
E. if (aString.equals("hello")) System.out.println("Hi");
Select all correct answers.


请选择: A B C D E

第38题(id号=372):

Consider the following code: What will be printed?
public class exceptiontest101{
  public static void main(String[]args){
    exceptiontest101 e = new exceptiontest101();
    e.myMethod();
  }

  void myMethod(){
   try{
     fragile() ;
   }catch(NullPointerException npex){
      System.out.println("NullPointerException thrown ");
   }catch(Exception ex){
     System.out.println("Exception thrown ");
   }finally{
     System.out.println("Done with exceptions ");
   }
   System.out.println("myMethod is done");
  }

   public void fragile() {
      throw new IllegalArgumentException();
   }
}
A. NullpointerException thrown
B. Exception thrown
C. Done with exceptions
D. D.myMethod is done


请选择: A B C D

第39题(id号=596):

How can you change the break statement below so that it breaks out of both the
inner and middle loops and continues with the next iteration of the outer loop?
outer: for (int x = 0; x < 3; x++) {
middle: for (int y = 0; y < 3; y++) {
inner: for (int z = 0; z < 3; z++) {
  if (arr(x, y, z) == targetValue)
    break;
  } } }
Select the one right answer.
a) break inner;
b) break middle;
c) break outer;
d) continue;
e) continue middle;


请选择: A B C D E

第40题(id号=75):

 Give the code fragment: 
if(x>4){ 
  System.out.println(“Test 1”);} 
else if (x>9){ 
  System.out.println(“Test 2”);} 
else { 
  System.out.println(“Test 3”);} 

Which range of value x would produce of output “Test 2”? 
A. x<4 
B. x>4 
C. x>9 
D. None 


请选择: A B C D

第41题(id号=299):

If s1 is declared as:
  String sl = "phenobarbital";
What will be the value of s2 after the following line of code:
String s2 = s1.substring( 3, 5 );
A. null
B. "eno"
C. "enoba"
D. "no"


请选择: A B C D E

第42题(id号=589):

What will happen when you compile and run this program:
class Array {
 public static void main(String[] args){
   int length = 100;
   int[] d = new int[length];
   for (int index = 0; index < length;index++)
    System.out.println(d[index]); }
   }
Select the one right answer.
a) The code will not compile because the int[] array is not declared correctly.
b) The code will compile but will throw an IndexArrayOutOfBoundsException when
   it runs and nothing will appear in the standard output.
c) The code will display the numbers 0 through 99 in the standard output, and
   then throw an IndexOutOfBoundsException.
d) The code will compile but the println() method will throw a
   NoSuchMethodException.
e) This code will work fine and display 100 zeroes in the standard output.


请选择: A B C D E

第43题(id号=260):

Consider the code below.
void myMethod(){
 try{
   fragile() ;
 }catch(NullPointerException npex){
   System.out.println("NullPointerException thrown ");
 }catch(Exception ex){
   System.out.println("Exception thrown ");
 }finally{
    System.out.println("Done with exceptions ");
 }
    System.out.println("myMethod is done");
 }
What is printed to standard output if fragile() throws an IllegalArgumentException?
A. "NullPointerException thrown"
B. "Exception thrown"
C. "Done with exceptions"
D. "myMethod is done"
E. Nothing is printed


请选择: A B C D E

第44题(id号=472):

What is the result of attempting to compiler and run the following piece of code.
 import java.awt.*;
 public class TestFrame extends Frame{
   public TestFrame() {
     Button one = new Button("One");
     Button two = new Button("Two");
     Button three = new Button("Three");
     setLayout(new FlowLayout());
     add(one);
     add(two);
     add(three);
     setSize(1000,1000);
     setVisible(true);
     two.setVisible(false);
 }
 public static void main(String args[]) {
     TestFrame tf = new TestFrame();
 }
}
Select one correct answer
a. If the above code runs, the buttons - one and three are laid out 
   in a single row from left to right with a gap in between.
b. If the above code runs, the buttons - one and three are laid out 
   in a single row from left to right with no gap in between.
c. Code does not compile - a component can not be hidden after being
   added to a container.
d. Code gets compiled successfully but throws runtime Exception - a 
   component can not be hidden after being added to a container.


请选择: A B C D

第45题(id号=360):

Consider the following program:
public class Test {
 public static void main(String args []) { 
   boolean a = false; 
   if (a =true)
      System.out.println("Hello");
   else
      System.out.println("Goodbye");
} }
What is the result:
A. Program produces no output but terminates correctly.
B. Program does not terminate.
C. Prints out "Hello"
D. Prints out "Goodbye"
Select the most appropriate answer.


请选择: A B C D

第46题(id号=568):

1. import java.awt.*;
2.
3. public class Birthdays extends Frame {
4. Birthdays() {
5. super("Birthday Reminder");
6. String lblsP1[] = {"Name:", "Birthday:", "Address:"};
7. String butnsP2[] = {"Add", "Save", "Exit"};
8. Panel panelTop = new Panel();
9. Panel panelBot = new Panel();
10. panelTop.setLayout(new GridLayout(3,2,3,3));
11. for(int x = 0; x < lblsP1.length; x++) {
12. panelTop.add(new Label(lblsP1[x]));
13. panelTop.add(new TextField());
14. }
15. for(int y = 0; y < butnsP2.length; y++) {
16. panelBot.add(new Button(butnsP2[y]));
17. }
18. add(panelTop, BorderLayout.NORTH);
19. add(panelBot, BorderLayout.SOUTH);
20. }
21. }
Which main method should you add to the Birthdays class to allow the program to
compile and run with all defined fields properly displayed?
A public static void main(String args[]) {
    Frame.visible = true;
  }
B public static void main(String args[]) {
    Frame f = new Frame();
    f.setVisible(true);
  }
C public static void main(String args[]) {
    Birthdays b = new Birthdays();
    b.pack();
    b.setVisible(true);
  }
D public static void main(String args[]) {
    Frame f = Birthdays.new Frame();
    f.pack();
    f.visible = true;
  }


请选择: A B C D

第47题(id号=371):

Consider the following code: What will be printed?
public class ExceptionTestMindQ{
  public static void main(String [] args){
   ExceptionTestMindQ e = new ExceptionTestMindQ();
   e.trythis();
 }
 public vo id trythis(){
  try{
     System.out.println("Innan testet");
     problem();
 }catch (NullPointerException x){
     System.out.println("Nullpointer");
 }catch(Exception x){
     System.out.println("Exception");
     return;
 }finally{
     System.out.println("finally");
 }
  System.out.println("mymethod is done");
 }

 public void problem()throws IllegalArgumentException{
    throw new IllegalArgumentException();
  }
}
A. Innan testet
B. Nullpointer
C. Exception
D. finally
E. mymethod is done


请选择: A B C D E

第48题(id号=470):

What is the result of attempting to compile and run the following program?
 public class AStringQuestion {
  static String s1;
  static String s2;
  public static void main(String args[]){
    s2 = s1+s2;
    System.out.println(s2);
 }
}
Select one correct answer
a. Will cause a compilation error.
b. Runtime Execption -NullPointerException in the 2nd line of the main method.
c. Will compile successfully and print "nullnull" on the screen.
d. Will compile successfully and print an empty line on the screen.


请选择: A B C D

第49题(id号=44):

Given the following code fragment:
  1  String str = null;
  2  if ((str != null) && (str.length() > 10)) {
  3 System.out.println("more than 10");
  4 } 
  5 else if ((str != null) & (str.length() < 5)) {
  6 System.out.println("less than 5");
  7 }
  8 else { System.out.println("end"); }
  Which line will cause error? 
  A. line 1
  B. line 2
  C. line 5
  D. line 8


请选择: A B C D

第50题(id号=452):

class Mystery {
   String s;
   public static void main(String args[]){
     Mystery m = new Mystery();
     m.go();
   }

   void Mystery() {
     s = "Constructor";
   }

   void go() {
     System.out.println(s);
   }
 }
a. The code compiles and throws an exception at run time.
b. The code runs, but nothing appears in the standard output.
c. The code runs, and "constructor" appears in the standard output.
d. The code runs and writes "null" in the standard output.


请选择: A B C D

第51题(id号=449):

Using a FlowLayout Manager, which of the following is the correct
way to add a component reference by the variable "c" to a container.
a. add(c)
b. c.add()
c. add("Center",c)
d. set(c)


请选择: A B C D E

第52题(id号=344):

In order to cause the paint(Graphics) method to execute, which of the following is the
most appropriate method to call:
A. paint()
B. repaint()
C. paint(Graphics)
D. update(Graphics)
E. None ? you should never cause paint(Graphics) to execute
Select the most appropriate answer.


请选择: A B C D E

第53题(id号=503):

Which of these are keywords in Java? 

A) default 
B) NULL 
C) String 
D) throws 
E) long 


请选择: A B C D E

第54题(id号=199):

 Given: 
1. class BaseClass { 
2.    Private float x = 1.0f ; 
3.     protected float getVar ( ) { return x;}
4. } 
5. class Subclass extends BaseClass {
6.       private float x = 2.0f; 
7.       //insert code here 
8. ) 
Which two are valid examples of method overriding? (Choose 
Two) 
A. float getVar ( ) { return x;} 
B. public float getVar ( ) { return x;} 
C. float double getVar ( ) { return x;} 
D. protected float getVar ( ) { return x;} 
E. public float getVar (float f ) { return f;} 


请选择: A B C D E

第55题(id号=159):

 which two statements declare an array capable of 10 ints? 
  A. int[] foo; 
  B. int foo[]; 
  C. int foo[10]; 
  D. Object[] foo; 
  E. Object foo[10]


请选择: A B C D E

第56题(id号=244):

Which statements on the<<< call>>> line are valid expressions?
public class SuperClass {
  public int x;
  int y;
  public void m1 (int a) {
  }
  Superclass(){
  }
}

class SubClass extends SuperClass{
 private float f;
 void m2() {
  return;
 }
 SubClass() {
 }
}

class T {
  public static void main (String [] args) {
   int i;
   float g;
   SubClass b = SubClass();
   <<< calls >>>
  }
}
A. b.m2();
B. g=b.f;
C. i=b.x;
D. i=b.y;
E. b.m1(6);


请选择: A B C D E

第57题(id号=500):

Which statements can be inserted at the indicated position in the following 
code to make the program write 1 on the standard output when run? 

public class Q4a39 { 
 int a = 1; 
 int b = 1; 
 int c = 1; 
 class Inner { 
  int a = 2; 
  int get() { 
   int c = 3; 
   // insert statement here 
   return c; 
 } 

 Q4a39() { 
  Inner i = new Inner(); 
  System.out.println(i.get()); 
 } 
  public static void main(String args[]) { 
    new Q4a39(); 
  } 


A) a = b; 
B) c = this.a; 
C) c = this.b; 
D) c = Q4a39.this.a; 
E) c = c; 


请选择: A B C D E

第58题(id号=319):

Which of the following is correct:
A. String temp [] = new String {"j" "a" "z"};
B. String temp [] = { "j " " b" "c"};
C. String temp = {"a", "b", "c"};
D. String temp [] = {"a", "b", "c"};
Select the most appropriate answer.


请选择: A B C D

第59题(id号=377):

Consider the following code: What will be printed?
public class Arraytest{
  public static void main(String kyckling[]){
    Arraytest a = new Arraytest();
    int i[] = new int[5];
    System.out.println(i[4]);
    a.amethod();
    Object o[] = new Object[5];
    System.out.println(o[2]);
  }

 void amethod(){
   int K[] = new int[4];
   System.out.println(K[3]);
 }
}
A. null null null
B. null 0 0
C. 0 0 null
D. 0 null 0


请选择: A B C D

第60题(id号=87):

Give the following class defination inseparate source files: 

    public class Example{ 
public Example(){//do something} 
protected Example(int i){//do something} 
protected void method(){//do something} 

public class Hello extends Example{//member method and member variable} 

Which methods are corrected added to the class Hello? 
A. public void Example(){} 
B. public void method(){} 
C. protected void method(){} 
D. private void method(){} 


请选择: A B C D


如果你想交卷,请点击提交按钮: