public class SomeException {
} Class a:
public class a {
public void doSomething() { }
} Class b:
public class b extends a {
public void doSomething() throws SomeException { }
}
Which is true about the two classes?()
A. Compilation of both classes will fail.
B. Compilation of both classes will succeed.
C. Compilation of class a will fail. Compilation of class b will succeed.
D. Compilation of class a will fail. Compilation of class a will succeed.
您可能感兴趣的试卷
你可能感兴趣的试题
23.int z=5;
24.
25. public void stuff1(int x) {
26. assert (x> 0);
27. switch(x) {
28. case 2: x= 3;
29. default: assert false; } }
30.
31. private void stuff2(int y) { assert (y < 0); }
32.
33. private void stuff3() { assert (stuff4O); }
34.
35. private boolean stuff4() { z = 6; return false; }
Which is true?()
A. All of the assert statements are used appropriately.
B. Only the assert statement on line 31 is used appropriately.
C. The assert statements on lines 29 and 31 are used appropriately.
D. The assert statements on lines 26 and 29 are used appropriately.
E. The assert statements on lines 29 and 33 are used appropriately.
F. The assert statements on lines 29, 31, and 33 are used appropriately.
G. The assert statements on lines 26, 29, and 31 are used appropriately.
public class Test {
public static void main(String [] args) {
boolean assert = true;
if(assert) {
System.out.println(”assert is true”);
}
}
}
Given:
javac -source 1.3 Test.java
What is the result?()
A. Compilation fails.
B. Compilation succeeds with errors.
C. Compilation succeeds with warnings.
D. Compilation succeeds without warnings or errors.
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 test {
public static void main(String [] a) {
assert a.length == 1;
}
}
Which two will produce an AssertionError?()
A. java test
B. java -ea test
C. java test file1
D. java -ea test file1
E. java -ea test file1 file2
F. java -ea:test test file1
public static void main(String[] args) {
for (int i=0;i<= 10;i++){
if( i>6) break;
}
System.out.println(i);
}
What is the result?()
A. 6
B. 7
C. 10
D. 11
E. Compilation fails.
F. An exception is thrown at runtime.
public static Iterator reverse(List list) {
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args) {
List list = new ArrayList();
list.add(” 1”); list.add(”2”); list.add(”3”);
for (Object obj: reverse(list))
System.out.print(obj + “,”);
}
What is the result?()
A. 3,2,1,
B. 1,2,3,
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
int x= 10;
do {
x--;
} while(x< 10);
How many times will line 37 be executed?()
A. ten times
B. zero times
C. one to me times
D. more than ten times
25.intx=12;
26. while (x < 10) {
27. x--;
28. }
29. System.out.print(x);
What is the result?()
A. 0
B. 10
C. 12
D. Line 29 will never be reached.
int x=0;
int y 10;
do {
y--;
++x;
} while (x < 5);
System.out.print(x + “,“ + y);
What is the result?()
A. 5,6
B. 5,5
C. 6,5
D. 6,6
Float pi = new Float(3.14f);
if(pi>3) {
System.out.print(”pi is bigger than 3. “);
}
else {
System.out.print(”pi is not bigger than 3. “);
}
finally {
System.out.println(”Have a nice day.”);
}
What is the result?()
A. Compilation fails.
B. pi is bigger than 3.
C. An exception occurs at runtime.
D. pi is bigger than 3. Have a nice day.
E. pi is not bigger than 3. Have a nice day.
![](https://static.ppkao.com/ppmg/img/appqrcode.png)
最新试题
Which two of statements are true?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
Which statement is true?()
Which two can be results?()
Which statement is true?()
What is the appropriate definition of the hashCode method in class Person?()
Given that t1 is a reference to a live thread, which is true?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
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 two are possible results?()