单项选择题

public class SwitchTest {  
public static void main (String args) {  
System.out.PrintIn(“value =” +switchIt(4));  
}  
public static int switchIt(int x) {  
int j = 1;  
switch (x) {  
case 1: j++;  
case 2: j++;  
case 3: j++; 
case 4: j++;  
case 5: j++;  
default:j++;  
}  
return j + x;  
}  
}  
What is the output from line 3? ()

A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8


您可能感兴趣的试卷

你可能感兴趣的试题

2.多项选择题Which two create an instance of an array?() 

A. int ia = new int [15];
B. float fa = new float [20];
C. char ca = “Some String”;
D. Object oa = new float[20];
E. Int ia = (4, 5, 6) (1, 2, 3)

3.单项选择题

public class Test {  
public static void main (String args) {  
class Foo {  
public int i = 3; 
}  
Object o = (Object) new Foo();  
Foo foo = (Foo)o;  
System.out.printIn(foo. i); 
}  
}  
What is the result?()  

A. Compilation will fail.
B. Compilation will succeed and the program will print “3”
C. Compilation will succeed but the program will throw a ClassCastException at line 6.
D. Compilation will succeed but the program will throw a ClassCastException at line 7.

4.多项选择题Which two declarations prevent the overriding of a method? ()

A. Final void methoda(){}
B. Void final methoda(){}
C. Static void methoda(){}
D. Static final void methoda(){}
E. Final abstract void methoda(){}

5.多项选择题

public class OuterClass {  
private double d1 1.0;  
//insert code here  
}  
You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()

A. static class InnerOne {  public double methoda() {return d1;}  }
B. static class InnerOne {  static double methoda() {return d1;}  }
C. private class InnerOne {  public double methoda() {return d1;}  }
D. protected class InnerOne {  static double methoda() {return d1;}  }
E. public abstract class InnerOne {  public abstract double methoda();  }

7.单项选择题How can you create a listener class that receives events when the mouse is moved?()  

A. By extending MouseListener.
B. By implementing MouseListener.
C. By extending MouseMotionListener.
D. By implementing MouseMotionListener.
E. Either by extending MouseMotionListener or extending MouseListener.
F. Either by implementing MouseMotion Listener or implementing MouseListener.

8.多项选择题

import java.awt.*;  
public class X extends Frame {  
public static void main (String args) {  
X x = new X();  
x.pack();  
x.setVisible(true);  
} 
public X() {  
setLayout (new BordrLayout());  
Panel p = new Panel ();  
add(p, BorderLayout.NORTH);  
Button b = new Button (“North”);  
p.add(b):  
Button b = new Button (“South”);  
add(b1, BorderLayout.SOUTH):  
}  
}  
Which two statements are true?()

A. The buttons labeled “North” and “South” will have the same width.
B. The buttons labeled “North” and “South” will have the same height.
C. The height of the button labeled “North” can very if the Frame is resized.
D. The height of the button labeled “South” can very if the Frame is resized.
E. The width of the button labeled “North” is constant even if the Frame is resized.
F. The width of the button labeled “South” is constant even if the Frame is resized.

9.单项选择题Which type of event indicates a key pressed on a java.awt.Component?()  

A. KeyEvent
B. KeyDownEvent
C. KeyPressEvent
D. KeyTypedEvent
E. KeyPressedEvent

10.单项选择题Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  

A. Abstract public void methoda();
B. Public abstract double methoda();
C. Static void methoda(double d1){}
D. Public native double methoda(){}
E. Protected void methoda(double d1){}

最新试题

Which three will compile and run without exception?()

题型:多项选择题

A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap.  Which two methods should be overridden to assure that Key works correctly as a key?()

题型:多项选择题

What is the result?()

题型:单项选择题

Given:  foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait().  From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()

题型:单项选择题

Which statement is true?()

题型:单项选择题

Given that t1 is a reference to a live thread, which is true?()

题型:单项选择题

Which three changes should be made to adapt this class to be used safely by multiple threads?()

题型:多项选择题

What is the result?()

题型:单项选择题

What is the result?()

题型:单项选择题

Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()

题型:多项选择题