Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in
Sequence
The Personne class
Core exercise
In Personne.java, create a class Personne (person) with the attributes nom (surname), prenom (first name), age, a constructor that initialises them, and a method afficherDetails() that prints the three values.
A workshop goes here: you write and run code in it. It requires JavaScript.
Starting code
Personne.java
public class Personne {
// TODO : les attributs nom, prenom, age
// TODO : le constructeur Personne(String nom, String prenom, int age)
public void afficherDetails() {
// TODO : afficher le nom, le prenom et l'age
}
}
Exercices.java
public class Exercices {
public static void main(String[] args) {
// Une fois Personne.java complete, remplacez cette ligne par :
// Personne p = new Personne("Dupont", "Jean", 18);
// p.afficherDetails();
System.out.println("Completez Personne.java, puis lancez Verifier.");
}
}
The core exercise is validated in the workshop, which requires JavaScript.
Hint 1
The constructor bears exactly the name of the class and has no return type, not even void. this.nom = nom; distinguishes the attribute from the parameter.