Skip to content

Commit

Permalink
feat: 🎸 appendix, tricks to succeed, translated
Browse files Browse the repository at this point in the history
Refers: #2
  • Loading branch information
rcmoutinho committed Sep 13, 2019
1 parent a5180b0 commit e6cc540
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions A-tricks-to-succeed.asc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[[A-tricks-to-succeed]]
[appendix]
== Dicas para ter sucesso na prova!
== Tips to succeed in the test!

Além de validar conceitos importantes da linguagem Java a prova de certificação também exigirá que você esteja atento a detalhes específicos nos códigos de cada questão. Sem o auxílio da IDE, você será o compilador.
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.

Veja alguns exemplos simples que se mostram óbvios mas podem te enganar na hora de marcar a resposta certa.
Here are some simple examples that are obvious but can trick you into marking the right answer.

=== Cenário 1
=== Scenario 1

[source,java]
----
Expand All @@ -19,29 +19,29 @@ class Duke {
}
}
----
. Compila e imprime "Java6"
. Compila e imprime "Java8"
. Não compila
. Compila, mas ocorre um erro durante a execução
. Compile and print "Java6"
. Compile and print "Java8"
. Not compile
. Compiles, but an error occurs while running

Sem pensar muito a reposta seria a _opção 1_, certo? Errado. Olhando mais atentamente ao código é possível notar que na primeira linha do método `main` está faltando um `;` (ponto-e-vírgula). Esse pequeno detalhe mostra que a opção certa é a 3.
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.

[TIP]
--
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.
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.

.Checklist mental para validar uma compilação
* Ponto-e-vírgula
* Visibilidade
* Escopo de variáveis
* Nomes e parâmetros de métodos
.Mental checklist to validate a build
* Semicolon
* Visibility
* Scope of variables
* Method names and parameters
* ...
--

- - -
_Resposta: 3_
_Answer: 3_

=== Cenário 2
=== Scenario 2

[source,java]
----
Expand All @@ -54,17 +54,17 @@ class Duke {
}
}
----
. O código compila e roda, imprimindo "Java8".
. O código não compila.
. O código compila e roda, imprimindo "Java6".
. O código compila mas dá erro em execução.
. The code compiles and runs, printing "Java8".
. The code does not compile.
. The code compiles and runs, printing "Java6".
. The code compiles but gives error in execution.

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[]`.
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.

- - -
_Resposta: 2_
_Answer: 2_

=== Cenário 3
=== Scenario 3

[source,java]
----
Expand All @@ -76,26 +76,26 @@ class Duke {
}
}
----
. Imprime `1`
. Imprime `0`
. Imprime `false`
. Imprime `true`
. Imprime `null`
. Erro de execução
. Não compila
. Print `1`
. Print `0`
. Print false
. Print `true`
. Print `null`
. Execution Error
. Not compile

A escolha mais comum seria a opção 3, onde confirma que o valor padrão de cada posição de um array do tipo _boolean_ é _false_. Esta opção estaria certa, se não fosse uma pegadinha. Este código na verdade *não compila*. A opção certa seria a número 7. Isso porque a variável _dukeClones_ é um _boolean_ simples tentando receber um array do tipo _boolean_.
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_.

[TIP]
--
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:
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:

* _boolean_ -> *_false_*
* _char_ -> *vazio*, equivalente a 0
* Primitivos numéricos inteiros -> *0*
* Primitivos numéricos com ponto flutuante -> *0.0*
* Referências (Objetos) -> *_null_*
* _char_ -> *empty*, equivalent to 0
* Integer Numeric Primitives -> *0*
* Floating-point numeric primitives -> *0.0*
* References (Objects) -> *_null_*
--

- - -
_Resposta: 7_
_Answer: 7_

0 comments on commit e6cc540

Please sign in to comment.