static void test() throws RuntimeException {
try {
System.out.print(”test “);
throw new RuntimeException();
}
catch (Exception ex) { System.out.print(”exception “); }
}
public static void main(String[] args) {
try { test(); }
catch (RuntimeException ex) { System.out.print(”runtime “); }
System.out.print(”end “);
}
What is the result?()
Given:
11.String test = "Test A. Test B. Test C.";
12.// insert code here
13.String[] result = test.split(regex);
Which regular expression, inserted at line 12,correctly splits test into "Test A","Test B",and "Test C"?()
int index = 1;
boolean[] test = new Boolean[3];
boolean foo= test [index];
What is the result?()
int index = 1;
boolean test = new Boolean;
boolean foo= test [index];
What is the result?()
现有:
interface Data {public void load();}
abstract class Info {public abstract void load();}
下列类定义中正确使用Data和Info的是哪项?()
class java {
public static void main(String [] java) {
for (int Java = 1; Java 〈 java.length; Java++)
System.out.print("java ");
}
}
和命令行:
java java java java java
结果为:()
Your network contains an Active Directory domain. All servers run Windows Server 2008 R2.
You need to audit the deletion of registry keys on each server.
What should you do()
An administrator is beginning a set of failover tests. The administrator would like to have clean log files foreach test.
Which command will achieve this?()
class Wrench {
public static void main(String [] args) {
Wrench w = new Wrench(); Wrench w2 = new Wrench();
w2 = go(w,w2);
System.out.print(w2 == w);
}
static Wrench go(Wrench wr1, Wrench wr2) {
Wrench wr3 = wr1; wr1 = wr2; wr2 = wr3;
return wr3;
}
}
结果是什么?()
现有:
class Tree {
private static String tree = "tree ";
String getTree () { return tree; }
}
class Elm extends Tree {
private static String tree = "elm ";
public static void main (String [] args) {
new Elm() .go (new Tree()) ;
}
}
void go (Tree t) {
String s = t.getTree () +Elm.tree + tree + (new Elm() .getTree ()) ;
System.out.println (s) ;}
结果为:()
public class TestOne {
public static void main (String[] args) throws Exception {
Thread.sleep(3000);
System.out.println(”sleep”);
}
}
What is the result?()
public class A extends Thread {
A() {
setDaemon(true);
}
public void run() {
(new B()).start();
try {
Thread.sleep(60000);
} catch (InterruptedException x) {}
System.out.println(“A done”);
}
class B extends Thread {
public void run() {
try {
Thread.sleep(60000);
} catch (InterruptedException x) {}
System.out.println(“B done”);
}
}
public static void main(String[] args) {
(new A()).start();
}
}
What is the result?()
public class TwoThreads {
private static Object resource = new Object();
private static void delay(long n) {
try { Thread.sleep(n); }
catch (Exception e) { System.out.print(”Error “); }
}
public static void main(String[] args) {
System.out.print(”StartMain “);
new Thread1().start();
delay(1000);
Thread t2 = new Thread2();
t2.start();
delay(1000);
t2.interrupt
delay(1000);
System.out.print(”EndMain “);
}
static class Thread 1 extends Thread {
public void run() {
synchronized (resource) {
System.out.print(”Startl “);
delay(6000);
System.out.print(”End1 “);
}
}
}
static class Thread2 extends Thread {
public void run() {
synchronized (resource) {
System.out.print(”Start2 “);
delay(2000);
System.out.print(”End2 “);
}
}
}
}
Assume that sleep(n) executes in exactly m milliseconds, and all other code executes in an insignificant amount of time. What is the output if the main() method is run?()
阅读以下代码:
public class Test{
public static void main(){
System.out.println(“x=”+x); } }
请问,代码运行的结果是?()
1. class Pizza {
2. java.util.ArrayList toppings;
3. public final void addTopping(String topping) {
4. toppings.add(topping);
5. }
6. }
7. public class PepperoniPizza extends Pizza {
8. public void addTopping(String topping) {
9. System.out.println(”Cannot add Toppings”);
10. }
11. public static void main(String[] args) {
12. Pizza pizza = new PepperoniPizza();
13. pizza.addTopping(”Mushrooms”);
14. }
15. }
What is the result?()
public class X {
public static void main (String[]args) {
string s = new string (“Hello”);
modify(s);
System.out.printIn(s);
}
public static void modify (String s) {
s += “world!”;
}
}
What is the result?()
分析下列Java代码:
class A {
public static void main(String[] args) {
method(); }
static void method() { try {
System.out.println("Hello"); System.exit(0); }
finally {
System.out.println("good-bye"); } } }
编译运行后,输出结果是()。
S0/0 on R1 is configured as a multipoint interface to communicate with R2 and R3 in the hub-and-spoke Frame Relay topology shown in the exhibit. Originally, static routes were configured between these routers to successfully route traffic between the attached networks. What will need to be done in order to use RIPv2 in place of the static routes?()
1. public class SimpleCalc {
2. public int value;
3. public void calculate() { value += 7; }
4. }
And:
1. public class MultiCalc extends SimpleCalc {
2. public void calculate() { value -= 3; }
3. public void calculate(int multiplier) {
4. calculate();
5. super.calculate();
6. value *=multiplier;
7. }
8. public static void main(String[] args) {
9. MultiCalc calculator = new MultiCalc();
10. calculator.calculate(2);
11. System.out.println(”Value is: “+ calculator.value);
12. }
13. }
What is the result?()
static void test() throws Error {
if (true) throw new AssertionError();
System.out.print(”test “);
}
public static void main(String[] args) {
try { test(); }
catch (Exception ex) { System.out.print(”exception “); }
System.out.print(”elld “);
}
What is the result?()
Given:
11. static class A {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println("B "); }
16. }
17. public static void main(String[] args) {
18. A a = new B();
19. a.process();
20. }
What is the result? ()
public class X {
public static void main(String [] args) {
try {
badMethod();
System.out.print(“A”);
}
catch (RuntimeException ex) {
System.out.print(“B”);
}
catch (Exception ex1) {
System.out.print(“C”);
}
finally {
System.out.print(“D”);
}
System.out.print(“E”);
}
public static void badMethod() {
throw new RuntimeException();
}
}
What is the result?()
public class Test {
public static void aMethod() throws Exception {
try {
throw new Exception();
} finally {
System.out.println(“finally”);
}
}
public static void main(String args[]) {
try {
aMethod();
} catch (Exception e) {
System.out.println(“exception”);
}
System.out.println(“finished”);
}
}
What is the result?()
现有:
void topGo() {
try {
middleGo();
} catch (Exception e) {
System.out.print("catch");
}
}
void middleGo() throws Exception {
go();
system.out.print("late middle");
}
void go() throws ExceptiOn {
throw new Exception();
}
如果调用 topGo () ,则结果为:()
public class Threads2 implements Runnable {
public void nun() {
System.out.println(”run.”);
throw new RuntimeException(”Problem”);
}
public static void main(String[] args) {
Thread t = new Thread(new Threads2());
t.start();
System.out.println(”End of method.”);
}
}
Which two can be results?()
static void test() throws RuntimeException {
try {
System.out.print(”test “);
throw new RuntimeException();
}
catch (Exception ex) { System.out.print(”exception “); }
}
public static void main(String[] args) {
try { test(); }
catch (RuntimeException ex) { System.out.print(”runtime “); }
System.out.print(”end “);
}
What is the result?()
11. static class A {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?()
11. static classA {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println(”B “); }
16. }
17. public static void main(String[] args) {
18.A a=new B();
19. a.process();
20.}
What is the result?()
import java.io.IOException;
public class ExceptionTest(
public static void main (Stringargs)
try (
methodA();
) catch (IOException e) (
system.out.printIn(“Caught IOException”);
) catch (Exception e) (
system.out.printIn(“Caught Exception”);
)
)
public void methodA () {
throw new IOException ();
}
What is the result?()
1. class Exc0 extends Exception { }
2. class Exc1 extends Exc0 { }
3. public class Test {
4. public static void main(String args[]) {
5. try {
6. throw new Exc1();
7. } catch (Exc0 e0) {
8. System.out.println(“Ex0 caught”);
9. } catch (Exception e) {
10. System.out.println(“exception caught”);
11. }
12. }
13. }
What is the result?()
现有:
class ThreadExcept implements Runnable {
public void run() { throw new RuntimeException("exception "); }
public static void main(String [] args) {
new Thread(new ThreadExcept()).start();
try {
int x = Integer.parseInt(args[0]);
Thread.sleep(x);
System.out.print("main ");
} catch (Exception e) { }
}
}
和命令行:
java ThreadExcept 1000
哪一个是结果?()
11.classA {
12. public void process() { System.out.print(”A “); } }
13. class B extends A {
14. public void process() throws RuntimeException {
15. super.process();
16. if (true) throw new RuntimeException();
17. System.out.print(“B”); }}
18. public static void main(String[] args) {
19. try { ((A)new B()).process(); }
20. catch (Exception e) { System.out.print(”Exception “); }
21. }
What is the result?()
11.classa {
12. public void process() { System.out.print(”a,”); } }
13. class b extends a {
14. public void process() throws IOException {
15. super.process();
16. System.out.print(”b,”);
17. throw new IOException();
18. } }
19. public static void main(String[] args) {
20. try { new b().process(); }
21. catch (IOException e) { System.out.println(”Exception”); } }
What is the result?()
免费的网站请分享给朋友吧