1. public class A {
2. public String doit(int x, int y) {
3. return “a”;
4. }
5.
6. public String doit(int... vals) {
7. return “b”;
8. }
9. }
Given:
25. A a=new A();
26. System.out.println(a.doit(4, 5));
What is the result?()
A. Line 26 prints “a” to System.out.
B. Line 26 prints „b” to System.out.
C. An exception is thrown at line 26 at runtime.
D. Compilation of class A will fail due to an error in line 6.
您可能感兴趣的试卷
你可能感兴趣的试题
1. public interface A {
2. public void doSomething(String thing);
3. }
1. public class AImpl implements A {
2. public void doSomething(String msg) { }
3. }
1. public class B {
2. public A doit() {
3. // more code here
4. }
5.
6. public String execute() {
7. // more code here
8. }
9. }
1. public class C extends B {
2. public AImpl doit() {
3. // more code here
4. }
5.
6. public Object execute() {
7. // more code here
8. }
9. }
Which statement is true about the classes and interfaces in the exhibit?()
A. Compilation will succeed for all classes and interfaces.
B. Compilation of class C will fail because of an error in line 2.
C. Compilation of class C will fail because of an error in line 6.
D. Compilation of class AImpl will fail because of an error in line 2.
class One {
void foo() {}
}
class Two extends One {
//insert method here
}
Which three methods, inserted individually at line 14, will correctly complete class Two?()
A. int foo() { /* more code here */ }
B. void foo() { /* more code here */ }
C. public void foo() { /* more code here */ }
D. private void foo() { /* more code here */ }
E. protected void foo() { /* more code here */ }
class One {
public One foo() { return this; }
}
class Two extends One {
public One foo() { return this; }
}
class Three extends Two {
// insert method here
}
Which two methods, inserted individually, correctly complete the Three class?()
A. public void foo() { }
B. public int foo() { return 3; }
C. public Two foo() { return this; }
D. public One foo() { return this; }
E. public Object foo() { return this; }
A JavaBeans component has the following field:
11. private boolean enabled;
Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
A. public void setEnabled( boolean enabled) public boolean getEnabled()
B. public void setEnabled( boolean enabled) public void isEnabled()
C. public void setEnabled( boolean enabled) public boolean isEnabled()
D. public boolean setEnabled( boolean enabled) public boolean getEnabled()
1. public class A {
2.
3. private int counter = 0;
4.
5. public static int getInstanceCount() {
6. return counter;
7. }
8.
9. public A() {
10. counter++;
11. }
12.
13. }
Given this code from Class B:
25.A a1 =new A();
26. A a2 =new A();
27. A a3 =new A();
28. System.out.printIn(A.getInstanceCount() );
What is the result?()
A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:
10. private int itemId;
11. private String name;
12. private String description;
Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?()
A. itemID(int itemId)
B. update(int itemId)
C. setItemId(int itemId)
D. mutateItemId(int itemId)
E. updateItemID(int itemId)
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways:
logIt(”log message 1 “);
logIt(”log message2”,”log message3”);
logIt(”log message4”, “log message5”, “log message6);
Which declaration satisfies this requirement?()
A. public void logIt(String * msgs)
B. public void logIt(String [] msgs)
C. public void logIt(String... msgs)
D. public void logIt(String msg1, String msg2, String msg3)
10. class Foo {
11. static void alpha() { /* more code here */ }
12. void beta() { /* more code here */ }
13. }
Which two are true?()
A. Foo.beta() is a valid invocation of beta().
B. Foo.alpha() is a valid invocation of alpha().
C. Method beta() can directly call method alpha().
D. Method alpha() can directly call method beta().
11. public static void main(String[] args) {
12. Object obj =new int[] { 1,2,3 };
13. int[] someArray = (int[])obj;
14. for (int i: someArray) System.out.print(i +“ “)
15. }
What is the result? ()
A. 1 2 3
B. Compilation fails because of an error in line 12.
C. Compilation fails because of an error in line 13.
D. Compilation fails because of an error in line 14.
E. A ClassCastException is thrown at runtime.
11. public enum Title {
12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms.”);
13. private final String title;
14. private Title(String t) { title = t; }
15. public String format(String last, String first) {
16. return title + “ “ + first + “ “ + last;
17. }
18. }
19. public static void main(String[] args) {
20. System.out.println(Title.MR.format(”Doe”, “John”));
21. }
What is the result?()
A. Mr. John Doe
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 20.
最新试题
What is the result?()
A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile?()
What can be a result?()
What is the result?()
What is the result?()
Which two are possible results?()
What is the result?()
What is the result?()
What is the result?()
What is the result?()