Questões de Concurso Público MEC 2011 para Analista de Sistemas
Foram encontradas 7 questões
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println(“cadence:“+cadence+”speed:
“+speed+”gear:“+gear);
}
}
class BicycleDemo {
public static void main(String[] args) {
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();v }
}
Ao final da execução desse trecho de programa, serão impressos os seguintes valores para bike2.
cadence:50 speed:20 gear:3
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println(“cadence:“+cadence+”speed:
“+speed+”gear:“+gear);
}
}
class BicycleDemo {
public static void main(String[] args) {
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();v }
}
De acordo com o trecho de programa em questão, o mecanismo de herança foi bloqueado pela redefinição de atributos na subclasse criada.
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println(“cadence:“+cadence+”speed:
“+speed+”gear:“+gear);
}
}
class BicycleDemo {
public static void main(String[] args) {
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();v }
}
O trecho de programa em apreço define instâncias da classe Bicycle.
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println(“cadence:“+cadence+”speed:
“+speed+”gear:“+gear);
}
}
class BicycleDemo {
public static void main(String[] args) {
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();v }
}
Ao final da execução desse trecho de programa, serão impressos os seguintes valores para bike1.
cadence:50 speed:10 gear:2
}
}
elseif ($react =="add_user") {
if (($user) and ($pass)) {
$query = “INSERT into login VALUES (“;
$query .= "0, SYSDATE( ),'$username','$password' )";
mysql_query($query, $mysql_link);
} else {
print(“<strong>either your user or password field
was left blank</strong><p>") ;
}
} else {
print("<center>Administration Area - Choose your
option</center>");
}
</script>
Não há crítica aos dados providos pelo usuário.
}
}
elseif ($react =="add_user") {
if (($user) and ($pass)) {
$query = “INSERT into login VALUES (“;
$query .= "0, SYSDATE( ),'$username','$password' )";
mysql_query($query, $mysql_link);
} else {
print(“<strong>either your user or password field
was left blank</strong><p>") ;
}
} else {
print("<center>Administration Area - Choose your
option</center>");
}
</script>
Os pares usuário e senha são armazenados em um banco de dados.
}
}
elseif ($react =="add_user") {
if (($user) and ($pass)) {
$query = “INSERT into login VALUES (“;
$query .= "0, SYSDATE( ),'$username','$password' )";
mysql_query($query, $mysql_link);
} else {
print(“<strong>either your user or password field
was left blank</strong><p>") ;
}
} else {
print("<center>Administration Area - Choose your
option</center>");
}
</script>
As informações são cifradas antes de sua inserção no banco de dados.