Looking for R1.01 - Initiation au développement test answers and solutions? Browse our comprehensive collection of verified answers for R1.01 - Initiation au développement at moodle.iut-tlse3.fr.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Quelle est la sortie console du programme suivant ?
fun buggyAbs(x: Int): Int {
var r = x
if (x < 0) {
r = x
}
check(r >= 0) { "negatif" }
return r
}
fun main() {
try {
println(buggyAbs(-2))
} catch (e: IllegalStateException) {
println("CHECK: ${e.message}")
}
}
Quelle est la valeur de finalResult après l'exécution de ce code ?
val x = 8
val y = 3
val z = 2
val finalResult = when (x % y) {
0 -> x / y
1 -> x + z
2 -> x * z
else -> x - y
}
Qu'affiche le code suivant ?
var i = 1
var sum = 0
while (i <= 3) {
sum += i
i++
}
println(sum)
Que se passe-t-il si on exécute le code suivant ?
val nombres = arrayOf(10, 20, 30)
println(nombres[3])
Quelle est la sortie console de ce programme ?
fun afficherInfo(age: Int, nom: String) {
print(">> ")
if (age < 0) {
print("Erreur : âge négatif ! ")
return
}
print("Nom : $nom, ")
print("Age : $age")
}
fun main() {
afficherInfo(0, "Ana")
afficherInfo(-2, "Bob")
}
Combien de fois s'affiche "Hello" avec ce code ?
var x = 10
while (x > 5) {
println("Hello")
x -= 3
}
Quel est le rôle d'un constructeur dans une classe ?
Quelle est la sortie console du programme suivant ?
fun main() {
for (i in 10 downTo 4 step 3) {
print("$i ")
}
}
Quelle est la sortie console du programme suivant ?
fun choisir(n: Int) {
when (n) {
1 -> print("Un. ")
else -> error("Choix invalide. ")
}
}
fun main() {
try {
choisir(3)
print("Ok. ")
} catch (e: IllegalStateException) {
print("OUPS")
}
}
Quelle est la valeur de output après l'exécution de ce code ?
val a = 2
val b = 5
val c = 3
val output = if (a < b) {
if (b > c) {
a + c } else { b - a}
} else {
c * 2
}