You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to validating important Java language concepts, the certification exam will also require you to be aware of specific details in the codes of each question. Without the help of the IDE, you will be the compiler.
6
6
7
-
Veja alguns exemplos simples que se mostram óbvios mas podem te enganar na hora de marcar a resposta certa.
7
+
Here are some simple examples that are obvious but can trick you into marking the right answer.
8
8
9
-
=== Cenário 1
9
+
=== Scenario 1
10
10
11
11
[source,java]
12
12
----
@@ -19,29 +19,29 @@ class Duke {
19
19
}
20
20
}
21
21
----
22
-
. Compila e imprime "Java6"
23
-
. Compila e imprime "Java8"
24
-
. Não compila
25
-
. Compila, mas ocorre um erro durante a execução
Without thinking too much the answer would be _option 1_, right? Wrong. Looking more closely at the code, you can see that the first line of the `main` method is missing a `;` (semicolon). This little detail shows that the right option is 3.
28
28
29
29
[TIP]
30
30
--
31
-
Sempre que existir uma resposta falando _código não compila_, verifique duas vezes as regras de compilação antes de testar o comportamento do código e sua possÃvel resposta.
31
+
Whenever there is a response saying _code does not compile_, double-check the compilation rules before testing the code's behavior and its possible answer.
Se você escolheu a opção 1, você errou... Esse exemplo tem outra pegadinha com o conceito de _shadowing_. Usa-se o mesmo nome de váriável mas com um escopo diferente. Inicialmente o tipo `int` engana sua reposta mas esse código não compila ao tentar atribuir um valor `int` à uma variável do tipo `String[]`.
62
+
If you chose option 1, you got it wrong... This example has another catch with the concept of _shadowing_. The same variable name is used but with a different scope. Initially the `int` type misleads its response but this code does not compile when trying to assign an `int` value to a `String[]` variable.
The most common choice would be option 3, where it confirms that the default value of each position of an array of type _boolean_ is _false_. This option would be right if it wasn't a catch. This code actually *does not compile*. The right option would be number 7. That's because the _dukeClones_ variable is a simple _boolean_ trying to get an array of type _boolean_.
88
88
89
89
[TIP]
90
90
--
91
-
Em uma inicialização implÃcita como membro de uma classe, ou cada posição de um array, etc, a variável recebe o valor padrão respeitando a seguinte regra:
91
+
In an implicit initialization as a member of a class, or each position of an array, etc., the variable gets the default value respecting the following rule:
0 commit comments