✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
public interface Max {
public double max( );
public int nombreElements
}
public final interface Stats extends Max{
public double somme( );
}
public class Groupe extends Stats {
private double[] valeurs = {3.2, 8.5, 6.1, 1.5, 2.8};
public double max
double maximum = valeurs[0];
for(int i=1; i < valeurs.length; i++) {
if (valeurs[i] > maximum) maximum = valeurs[i];
}
return maximum;
}
public double somme
double accum = 0.0;
for(int i=0; i < valeurs.length ; i++)
accum+=valeurs [i];
return accum;
}
public double get(int index) { return valeurs[index]; }
public static void main(String[] args) {
Groupe mmGroupe = new Groupe();
System.out.println("Max mmGroupe " + mmGroupe.max
System.out.println("somme mmGroupe " + ((Stats) mmGroupe).somme());
System.out.println("dernier element " + mmGroupe.get(7) );
}
}
|
a) Dans le code, il y a quatre erreurs, trouvez-les. Justifiez votre réponse.
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!