Questões de Concurso Comentadas sobre programação
Foram encontradas 10.880 questões
“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.
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;
}
}
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();
}
}
namespace ConsoleApplication1
{
class Program
{
static IEnumerable<int>
XPTO(int from, int to) {
for (int i = from; i < to; i+=3) {
yield return i;
}
yield break;
}
static void Main()
{
foreach (int x in XPTO(-10, 10) {
Console.WriteLine(x);
}
}
}
}
O resultado exibido pelo programa é:
var x = 3 + "4";
Após a execução deste comando, a variável x conterá:
public class Calcular {
public void verificar(double a, double b){
if((a+b < a+4) && ((3*a < b/2) || (a!=b))){
System.out.print("True");
} else{
System.out.print("False");
}
}
public boolean verificar(int a, int b){
if((a+b < a+4) && ((3*a < b/2) || (a!=b))){
return true;
} else{
return false;
}
}
}
Pode-se concluir corretamente que
import javax.ejb.*;
@Local
public interface CalculadoraLocal {
double somar(double x, double y);
}
import javax.ejb.*;
import com.ejbs.interfaces.CalculadoraLocal;
public class CalculadoraBean implements CalculadoraLocal {
@Override
public double somar(double x, double y) {
return x + y;
}
}
Para indicar que a classe CalculadoraBean é um bean de sessão sem estado, deve-se
Com relação a Servlet, identifique as afirmativas a seguir como verdadeiras (V) ou falsas (F):
( ) Uma Servlet é um objeto Java que recebe requisições (request) e produz algo (response), como uma página HTML dinamicamente gerada.
( ) O comportamento de uma Servlet geralmente é definido pela classe HttpServlet do pacote javax.servlet.
( ) A classe HttpServlet gera aplicações Web baseadas no protocolo HTTP, mas deve-se observar que Servlets não foram criadas somente para esse protocolo.
Assinale a alternativa que apresenta a sequência correta, de cima para baixo.