Студопедия

КАТЕГОРИИ:

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


Click the Exhibit button.




11. public class Bootchy {

12. int bootch;

13. String snootch;

14.

15. public Bootchy() {

16. this("snootchy");

17. System.out.print("first ");

18. }

19.

20. public Bootchy(String snootch) {

21. this(420, "snootchy");

22. System.out.print("second ");

23. }

24.

25. public Bootchy(int bootch, String snootch) {

26. this.bootch = bootch;

27. this.snootch = snootch;

28. System.out.print("third ");

29. }

30.

31. public static void main(String[] args) {

32. Bootchy b = new Bootchy();

33. System.out.print(b.snootch +" " + b.bootch);

34. }

35. }

What is the result?

A. snootchy 420 third second first

B. snootchy 420 first second third

C. first second third snootchy 420

D. third second first siiootchy 420

E. third first second snootchy 420

F. first second first third snootchy 420

 

59. Given:

11. public class Test {

12. public enum Dogs {collie, harrier, shepherd};

13. public static void main(String [] args) {

14. Dogs myDog = Dogs.shepherd;

15. switch (myDog) {

16. case collie:

17. System.out.print("collie ");

18. case default:

19. System.out.print("retriever ");

20. case harrier:

21. System.out.print("harrier ");

22. }

23. }

24. }

What is the result?

A. harrier

B. shepherd

C. retriever

D. Compilation fails.

E. retriever harrier

F. An exception is thrown at runtime.

 

60. Given:

11. public void testIfA() {

12. if(testIfB("True")) {

13. System.out.println("True");

14. } else {

15. System.out.println("Not true");

16. }

17. }

18. public Boolean testIfB(String str) {

19. return Boolean.valueOf(str);

20. }

What is the result when method testIfA is invoked?

A. True

B. Not true

C. An exception is thrown at runtime.

D. Compilation fails because of an error at line 12.

E. Compilation fails because of an error at line 19.

 

61. Given:

11. public static void main(String[] args) {

12. Integer i = new Integer(1) + new Integer(2);

13. switch(i) {

14. case 3: System.out.println("three"); break;

15. default: System.out.println("other"); break;

16. }

17. }

What is the result?

A. three

B. other

C. An exception is thrown at runtime.

D. Compilation fails because of an error on line 12.

E. Compilation fails because of an error on line 13.

F. Compilation fails because of an error on line 15.

62. Given:

11. public static void main(String[] args) {

12. String str = "null';

13. if (str == null) {

14. System.out.println("null');

15. } else (str.length() == 0) {

16. System.out.println("zero");

17. } else {

18. System.out.println("some");

19. }

20. }

What is the result?

A. null

B. zero

C. some

D. Compilation fails.

E. An exception is thrown at runtime.

 

 

63. Given:

11. Float pi = new Float(3.14f);

12. if(pi>3) {

13. System.out.print("pi is bigger than 3. ");

14. }

15. else {

16. System.out.print("pi is not bigger than 3. ");

17. }

18. finally {

19. System.out.println("Have a nice day.");

20. }

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.

 

64. Given:

10. int x=0;

11. int y 10;

12. do {

l3. y--;

14. ++x;

15. } while (x < 5);

16. System.out.print(x + "," + y);

What is the result?

A. 5,6

B. 5,5

C. 6,5

D. 6,6

 

 

65. Given:

25. int x=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.

 

66. Given:

35. int x= 10;

36. do {

37. x--;

38. } 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

 

67. Give:

11. public static Iterator reverse(List list) {

12. Collections.reverse(list);

13. return list.iterator();

14. }

15. public static void main(String[] args) {

16. List list = new ArrayList();

17. list.add(" 1"); list.add("2"); list.add("3");

18. for (Object obj: reverse(list))

19. System.out.print(obj + ",");

20. }

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.

 

68. Given:

11. public static Collection get() {

12. Collection sorted = new LinkedList();

13. sorted.add('B"); sorted.add("C"); sorted.add("A");

14. return sorted;

15. }

16. public static void main(String[] args) {

17. for (Object obj: get()) {

18. System.out.print(obj + ", ");

19. }

20. }

What is the result?

A. A, B, C, B. B, C, A, C. Compilation fails.

D. The code runs with no output.

E. An exception is thrown at runtime.

69. Given:

11. public static void main(String[] args) {

12. for (int i=0;i<= 10;i++){

13. if( i>6) break;

14. }

15. System.out.println(i);

16. }

What is the result?

A. 6

B. 7

C. 10

D. 11

E. Compilation fails. F. An exception is thrown at runtime.

70. Given:

8. public class test {

9. public static void main(String [] a) {

10. assert a.length == 1;

11. }

12. }

Which two will produce an AssertionError? (Choose two.)

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

 

 

71. Given:

12. public class AssertStuff {

13.

14. public static void main(String [] args) {

15. int x= 5;

16. int y= 7;

17.

18. assert (x> y): "stuff";

19. System.out.println("passed");

20. }

21. }

And these command line invocations:


Поделиться:

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





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