Questões de Concurso Público BANPARÁ 2015 para Técnico em Informática
Foram encontradas 4 questões
public class A {
public int c;
private String d;
}
class B extends A {
private boolean e;
public void g() {
c = 5;
d = "BELÉM";
}
}
class C {
public void f() {
A x = new A();
B y = new B();
}
}
public class BancoDados {
private static Connection conexao;
public static Connection getConexao() {
try {
if (conexao == null) {
Class.forName("org.firebirdsql.jdbc.FBDriver");
conexao =
DriverManager.getConnection("jdbc:firebirdsql://12
7.0.0.1:3050/C:/Banco.fdb", "SYSDBA",
"masterkey");
}
return conexao;
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null,
"Mensagem A");
} catch (SQLException e) {
JOptionPane.showMessageDialog(null,
"Mensagem B");
}
return null;
}
}
“Developers seem to agree that one of the most important qualities of code is its readability. Code that's written in a way that makes it easy for other programmers to understand with a minimal amount of time and effort is considered top notch.
“I feel that if I can't understand the author's intent in 5 minutes or less, the coder did a bad job," said Luke Burnham, a senior software engineer at Lionbridge. “The computer doesn't care about variable names or line spacing but people do. Code is written once but read hundreds of times over its lifetime. Using meaningful variable names and injecting spaces in order to increase the readability of the code will make code better."
An anonymous senior web application developer with more than a decade of professional programming experience also recommended to me that writing good code means, “Following a consistent coding style (proper spacing, indentation, general flow)." He also emphasized the importance of choosing “Variable names that make sense."
“Wrap Early, Wrap Often," is the personal policy of Neil Best, a senior application developer at Gogo. “This may be a personal preference / style thing, but I go for tall over wide, not to inflate my line counts but actually to increase legibility," he told me. “If a function has two arguments put them on two new lines. If an arithmetic expression has many terms give them each their own line. Your interpreter may require you to use trailing operators (RTFM) but it's worth it." In short, more readable equals more understandable which makes everyone's life easier.
“The faster someone can look at it and understand it. The faster the application will move forward (feature and revenue)," said commenter Glennular on Stack Overflow. Or, as Stack Exchange user mojuba put it, “There is really no good criteria other than how fast you can understand the code." www.javaworld.com em 26/09/2015.