public class AssertStuff { public static void main(String [] args) { int x= 5; int y= 7; assert (x> y): “stuff”; System.out.println(”passed”); } } And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()
A、 passed stuff
B、 stuff passed
C、 passed An AssertionError is thrown with the word “stuff” added to the stack trace.
D、 passed An AssertionError is thrown without the word “stuff” added to the stack trace.
E、 passed An AssertionException is thrown with the word “stuff” added to the stack trace.
F、 passed An AssertionException is thrown without the word “stuff” added to the stack trace.
相关问题推荐
-
public class Yippee2 { static public void main(String [] yahoo) { for(int x= 1; xSystem.out.print(yahoo[x] + “ “); } } } and the command line invocation: java Yippee2 a b c What is the result?()
A、a b
B、b c
C、a b c
D、 Compilation fails.
E、 An exception is thrown at runtime.
-
Consider the following class: class Test(int i) { void test(int i) { System.out.println(“I am an int.”); } void test(String s) { System.out.println(“I am a string.”); } public static void main(String args) { Test t=new Test(); char ch=“y”; t.test(ch); } } Which of the statements below is true?()
A、 Line 5 will not compile, because void methods cannot be overridden.
B、 Line 12 will not compile, because there is no version of test() that rakes a charargument.
C、 The code will compile but will throw an exception at line 12.
D、 The code will compile and produce the following output: I am an int.
E、 The code will compile and produce the following output: I am a String.
-
Which method in the Thread class is used to create and launch a new thread of execution?()
A、 Run();
B、 Start();
C、 Execute();
D、 Run(Runnable r);
E、 Start(Runnable r);
F、 Execute(Thread t);
-
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
Amove the line 12 print statement into the foo() method
Bchange line 7 to public synchronized void go(){
Cchange the variable declaration on line 2 to private volatile int x;
Dwrap the code inside the foo() method with a synchronized(this) block
Ewrap the for loop code inside the go() method with a synchronized block synchronized(this){//for loop code here}
-
Assume that country is set for each class. Given: 10. public class Money { 11. private String country, name; 12. public getCountry() { return country; } 13.} and: 24. class Yen extends Money { 25. public String getCountry() { return super.country; } 26. } 27. 28. class Euro extends Money { 29. public String getCountry(String timeZone) { 30. return super.getCountry(); 31. } 32. } Which two are correct?()
AYen returns correct values.
BEuro returns correct values.
CAn exception is thrown at runtime.
DYen and Euro both return correct values.
ECompilation fails because of an error at line 25.
FCompilation fails because of an error at line 30.