Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ques-Только тут иногда ошибки мне встретились, редко, но все же.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
240 Кб
Скачать
☆

50. Click the Exhibit button.

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.

51. Click the Exhibit button.

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.

52. Given:

1. public class A {

2. public void doit() {

3. }

4. public String doit() {

5. return "a";

6. }

7. public double doit(int x) {

8. return 1.0;

9. }

10.}

What is the result?

A. An exception is thrown at runtime.

B. Compilation fails because of an error in line 7.

C. Compilation fails because of an error in line 4.

D. Compilation succeeds and no runtime errors with class A occur.

53. Given:

10. class Line {

11. public static class Point { }

12. }

13.

14. class Triangle {

15. // insert code here

16. }

Which code, inserted at line 15, creates an instance of the Point class defined in Line?

A. Point p = new Point();

B. Line.Point p = new Line.Point();

C. The Point class cannot be instatiated at line 15.

D. Line 1 = new Line() ; 1.Point p = new 1.Point();

54. Given:

10. class Line {

11. public class Point { public int x,y; }

12. public Point getPoint() { return new Point(); }

13. }

14. class Triangle {

15. public Triangle() {

16. // insert code here

17. }

18. }

Which code, inserted at line 16, correctly retrieves a local instance of a Point object?

A. Point p = Line.getPoint();

B. Line.Point p = Line.getPoint();

C. Point p = (new Line()).getPoint();

D. Line.Point p = (new Line()).getPoint();

55. Given:

10. class One {

11. public One() { System.out.print(1); }

12. }

13. class Two extends One {

14. public Two() { System.out.print(2); }

15. }

16. class Three extends Two {

17. public Three() { System.out.print(3); }

18. }

19. public class Numbers{

20. public static void main( String[] argv) { new Three(); }

21. }

What is the result when this code is executed?

A. 1

B. 3

C. 123

D. 321

E. The code rims with no output.