Questões de Concurso Público MEC 2011 para Analista de Sistemas

Foram encontradas 7 questões

Q268142 Programação
class 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 }
}
Considerando o trecho de programa Java mostrado acima, julgue o  item  seguinte.

Ao final da execução desse trecho de programa, serão impressos os seguintes valores para bike2.

cadence:50  speed:20 gear:3

Alternativas
Q268143 Programação
class 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 }
}
Considerando o trecho de programa Java mostrado acima, julgue o item seguinte.

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.
Alternativas
Q268144 Programação
class 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 }
}
Considerando o trecho de programa Java mostrado acima, julgue os itens seguintes.

O trecho de programa em apreço define instâncias da classe Bicycle.
Alternativas
Q268145 Programação
class 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 }
}
Considerando o trecho de programa Java mostrado acima, julgue o  item  seguinte.

Ao final da execução desse trecho de programa, serão impressos os seguintes valores para bike1.

cadence:50 speed:10 gear:2
Alternativas
Q268146 Programação
<script language=“php">
if($react == “delete_user") {
if($user) {
$query = “DELETE from login WHERE user='$user'";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
print(“<strong>$user</strong> successfully
deleted<p>");
}
} else {
print(“<strong>no users are available to delete
.</strong><p>");

}

}

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>



 

Considerando o trecho de programa PHP apresentado acima, julgue o item subsequente.

Não há crítica aos dados providos pelo usuário.
Alternativas
Q268147 Programação
<script language=“php">
if($react == “delete_user") {
if($user) {
$query = “DELETE from login WHERE user='$user'";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
print(“<strong>$user</strong> successfully
deleted<p>");
}
} else {
print(“<strong>no users are available to delete
.</strong><p>");

}

}

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>



 

Considerando o trecho de programa PHP apresentado acima, julgue o  item  subsequente.

Os pares usuário e senha são armazenados em um banco de dados.
Alternativas
Q268148 Programação
<script language=“php">
if($react == “delete_user") {
if($user) {
$query = “DELETE from login WHERE user='$user'";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
print(“<strong>$user</strong> successfully
deleted<p>");
}
} else {
print(“<strong>no users are available to delete
.</strong><p>");

}

}

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>



 

Considerando o trecho de programa PHP apresentado acima, julgue o  item  subsequente.


As informações são cifradas antes de sua inserção no banco de dados.
Alternativas
Respostas
1: E
2: E
3: C
4: C
5: C
6: C
7: E