Question 67
Given:
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 (stuff4()); }
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.
dar uma olhada nas regras assert e tenta descobrir pq a 26 e 33 nao sao falsas!!
Bom eu poderia dar a resposta para vc… mais como estar se preparando para certificacao, vc tirar suas proprias conclusoes, a partir da leitura das regras de acordo com a sintaxe dada, vc acaba aprendendo mais que apenas eu ti dizer… ja que no exame vc vai ter q fazer isso todo o tempo, lembrar das regras, e aplicar na sintaxe da questao…
flw!! caso fique com duvida, so gritar!!
bons estudos!
Question 67
Given:
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 (stuff4()); }
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.
Answer: C
Qual o problema dos assert das linhas 26 e 33 ?[/quote]
Acho que esta questão caiu na minha prova quando eu fiz a SCJP. Se não foi esta, foi uma bem parecida.