Студопедия

КАТЕГОРИИ:

АстрономияБиологияГеографияДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРиторикаСоциологияСпортСтроительствоТехнологияФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника


Click the Exhibit button. 5. public static int getInstanceCount() {




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.

 

 

47. 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? (Choose two.)

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()

 

48. Given:

10. class One {

11. public One foo() { return this; }

12. }

13. class Two extends One {

14. public One foo() { return this; }

15. }

16. class Three extends Two {

17. // insert method here

18. }

Which two methods, inserted individually, correctly complete the Three class?

(Choose two.)

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; }

 

49. Given:

10. class One {

11. void foo() {}

12. }

13. class Two extends One {

14. //insert method here

15. }

Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)

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 */ }

 

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.

 


Поделиться:

Дата добавления: 2015-09-13; просмотров: 150; Мы поможем в написании вашей работы!; Нарушение авторских прав





lektsii.com - Лекции.Ком - 2014-2024 год. (0.007 сек.) Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав
Главная страница Случайная страница Контакты