Procura

ProgramaçãoLinguagens de programação


EXERCÍCIOS - Exercício 484

  • (CESPE 2011)

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.


C) Certo

E) Errado


Próximo:
EXERCÍCIOS - Exercício 485

Vamos para o Anterior: Exercício 483

Tente Este: Exercício 317

Primeiro: Exercício 1

VOLTAR ao índice: Programação






Cadastre-se e ganhe o primeiro capítulo do livro.
+
((ts_substr_ig=0.00ms))((ts_substr_id=3.33ms))((ts_substr_m2=0.00ms))((ts_substr_p2=0.63ms))((ts_substr_c=1.20ms))((ts_substr_im=0.76ms))
((total= 6ms))