多项选择题

public class MethodOver {  
private int x, y;  
private float z;  
public void setVar(int a, int b, float c){  
x = a;  
y = b;  
z = c;  
}  
}  
Which two overload the setVar method?()

A. void setVar (int a, int b, float c){  x = a;  y = b;  z = c;  }
B. public void setVar(int a, float c, int b) {  setVar(a, b, c);  }
C. public void setVar(int a, float c, int b) {  this(a, b, c);  }
D. public void setVar(int a, float b){  x = a;  z = b;  }
E. public void setVar(int ax, int by, float cz) {  x = ax;  y = by;  z = cz;  }


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

class A {  
public String toString () {  
return “4”;  
}  
}  
class B extends A {  
8. public String toString () {  
return super.toString() + “3”;  
}  
}  
public class Test {  
public static void main(Stringargs) {  
System.out.printIn(new B());  
}  
}  
What is the result?()  

A. Compilation succeeds and 4 is printed.
B. Compilation succeeds and 43 is printed.
C. An error on line 9 causes compilation to fail.
D. An error on line 14 causes compilation to fail.
E. Compilation succeeds but an exception is thrown at line 9.

2.多项选择题Which two demonstrate encapsulation of data? ()

A. Member data have no access modifiers.
B. Member data can be modified directly.
C. The access modifier for methods is protected.
D. The access modifier to member data is private.
E. Methods provide for access and modification of data.

3.单项选择题Which code determines the int value foo closest to a double value bar?()  

A. Int foo = (int) Math.max(bar);
B. Int foo = (int) Math.min(bar);
C. Int foo = (int) Math.abs(bar);
D. Int foo = (int) Math.ceil(bar);
E. Int foo = (int) Math.floor(bar);
F. Int foo = (int) Math.round(bar);

4.单项选择题

public class Test {  
public static void main (String args) { 
string foo = “blue”; 
string bar = foo;  
foo = “green”;  
System.out.printIn(bar);  
}  
}  
What is the result?()  

A. An exception is thrown.
B. The code will not compile.
C. The program prints “null”
D. The program prints “blue”
E. The program prints “green”

5.单项选择题Which can be used to decode charS for output?()  

A. Java.io.InputStream.
B. Java.io.EncodedReader.
C. Java.io.InputStreamReader.
D. Java.io.InputStreamWriter.
E. Java.io.BufferedInputStream.

6.单项选择题Which constructs a DataOutputStream?()  

A. New dataInputStream(“in.txt”);
B. New dataInputStream(new file(“in.txt”));
C. New dataInputStream(new writer(“in.txt”));
D. New dataInputStream(new FileWriter(“in.txt”));
E. New dataInputStream(new InputStream(“in.txt”));
F. New dataInputStream(new FileInputStream(“in.txt”));

7.单项选择题

public class Foo implements Runnable ( 
public void run (Thread t) {  
system.out.printIn(“Running.”);  
}  
public static void main (String args) {  
new thread (new Foo()).start();  
}  
)  
What is the result?()  

A. An exception is thrown.
B. The program exists without printing anything.
C. An error at line 1 causes compilation to fail.
D. An error at line 6 causes the compilation to fail.
E. “Running” is printed and the program exits.

8.多项选择题Which two can directly cause a thread to stop executing?() 

A. Exiting from a synchronized block.
B. Calling the wait method on an object.
C. Calling the notify method on an object.
D. Calling the notifyAll method on an object.
E. Calling the setPriority method on a thread object.

9.单项选择题

public class ForBar {  
public static void main(String args) {  
int i = 0, j = 5;  
tp: for (;;) {  
i ++;  
for(;;)  
if(i > --j) break tp;  
}  
system.out.printIn(“i = ” + i + “, j = “+ j);  
}  
}  
What is the result? () 

A. The program runs and prints “i=1, j=0”
B. The program runs and prints “i=1, j=4”
C. The program runs and prints “i=3, j=4”
D. The program runs and prints “i=3, j=0”
E. An error at line 4 causes compilation to fail.
F. An error at line 7 causes compilation to fail.

10.多项选择题Which four types of objects can be thrown using the throw statement?()

A. Error
B. Event
C. Object
D. Exception
E. Throwable
F. RuntimeException