App Dev Worksheet: Events
Developer's tip (When this, do that): Event → handler → action: “on tap, do this”. The handler runs once for every tap. Counter: start + taps × step. A limit stops it growing; on = !on flips ON / OFF.
NameDateTime takenScore ___ / 40
-
1.👆 The user types Riya in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Welcome, " + nameBox.text + "!";
}; (a) Welcome, nameBox.text! (b) Riya (c) Welcome! (d) Welcome, Riya! -
2.👆 The user types Riya in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hi, " + nameBox.text + "!";
}; (a) Riya (b) Hi, nameBox.text! (c) Hi, Riya! (d) Hi! - 3.👆 What kind of event is this: the user presses Save? (a) a text event (b) a timer event (c) a tap event (d) a load event
- 4.True or false: the screen first opens is a load event. (a) False (b) True
-
5.👆 The user types Arjun in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hi, " + nameBox.text + "!";
}; (a) Arjun (b) Hi, nameBox.text! (c) Hi! (d) Hi, Arjun! - 6.👆 What kind of event is this: a 5-minute alarm ends? (a) a load event (b) a tap event (c) a timer event (d) a text event
- 7.True or false: the screen first opens is a tap event. (a) False (b) True
-
8.👆 The user taps the button 1 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 2) {
likes = likes + 1;
}
label.text = likes;
}; -
9.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Welcome, " + nameBox.text + "!";
}; (a) Welcome, nameBox.text! (b) Aman (c) Welcome, Aman! (d) Welcome! -
10.👆 The user types Meera in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hello, " + nameBox.text + "!";
}; (a) Meera (b) Hello, nameBox.text! (c) Hello! (d) Hello, Meera! - 11.👆 What kind of event is this: the user taps Play? (a) a timer event (b) a text event (c) a tap event (d) a load event
- 12.👆 A tap handler runs how many times if the user taps 4 times? (a) 4 (b) 8 (c) 1 (d) 0
-
13.👆 The user taps the button 2 times. What does the label show now?
let on = false;
button.onTap = function () {
on = !on;
if (on) {
label.text = "ON";
} else {
label.text = "OFF";
}
}; (a) OFF (b) ON -
14.👆 The user taps the button 3 times. What number does the label show now?
let points = 3;
button.onTap = function () {
points = points + 3;
label.text = points;
}; - 15.👆 Code that runs when an event happens is called a ___. (a) headline (b) handler (c) hashtag (d) header
- 16.True or false: a 5-minute alarm ends is a timer event. (a) False (b) True
-
17.👆 The user taps the button 1 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 4) {
likes = likes + 1;
}
label.text = likes;
}; - 18.👆 What kind of event is this: one second passes? (a) a load event (b) a tap event (c) a timer event (d) a text event
-
19.👆 The user taps the button 7 times. What does the label show now?
let on = false;
button.onTap = function () {
on = !on;
if (on) {
label.text = "ON";
} else {
label.text = "OFF";
}
}; (a) OFF (b) ON -
20.👆 The user types Kabir in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Well done, " + nameBox.text + "!";
}; (a) Kabir (b) Well done! (c) Well done, nameBox.text! (d) Well done, Kabir! - 21.👆 What kind of event is this: a finger hits Like? (a) a load event (b) a tap event (c) a timer event (d) a text event
-
22.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hello, " + nameBox.text + "!";
}; (a) Aman (b) Hello, Aman! (c) Hello, nameBox.text! (d) Hello! -
23.👆 The user taps the button 4 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 2) {
likes = likes + 1;
}
label.text = likes;
}; -
24.👆 The user taps the button 3 times. What does the label show now?
let on = false;
button.onTap = function () {
on = !on;
if (on) {
label.text = "ON";
} else {
label.text = "OFF";
}
}; (a) ON (b) OFF - 25.👆 What kind of event is this: the app starts up? (a) a text event (b) a load event (c) a tap event (d) a timer event
-
26.👆 The user taps the button 2 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 5) {
likes = likes + 1;
}
label.text = likes;
}; -
27.👆 The user taps the button 6 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 2) {
likes = likes + 1;
}
label.text = likes;
}; -
28.👆 The user taps the button 3 times. What number does the label show now?
let points = 1;
button.onTap = function () {
points = points + 3;
label.text = points;
}; - 29.👆 What kind of event is this: the screen first opens? (a) a timer event (b) a load event (c) a text event (d) a tap event
- 30.👆 “On tap → do this” links an event to ___. (a) a charger (b) a font (c) an action (d) a web address
- 31.True or false: the user taps Play is a tap event. (a) False (b) True
- 32.True or false: the user taps Play is a load event. (a) True (b) False
-
33.👆 The user taps the button 5 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 3) {
likes = likes + 1;
}
label.text = likes;
}; -
34.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Well done, " + nameBox.text + "!";
}; (a) Well done, Aman! (b) Well done, nameBox.text! (c) Aman (d) Well done! -
35.👆 The user taps the button 6 times. What does the label show now?
let on = false;
button.onTap = function () {
on = !on;
if (on) {
label.text = "ON";
} else {
label.text = "OFF";
}
}; (a) ON (b) OFF -
36.👆 The user taps the button 5 times. What number does the label show now?
let coins = 7;
button.onTap = function () {
coins = coins + 5;
label.text = coins;
}; - 37.True or false: the search box changes is a tap event. (a) False (b) True
-
38.👆 The user types Zoya in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hi, " + nameBox.text + "!";
}; (a) Hi, Zoya! (b) Hi! (c) Hi, nameBox.text! (d) Zoya - 39.True or false: the screen first opens is a text event. (a) True (b) False
- 40.True or false: the user presses Save is a tap event. (a) False (b) True
Answer key
- Welcome, Riya!
- Hi, Riya!
- a tap event
- True
- Hi, Arjun!
- a timer event
- False
- 1
- Welcome, Aman!
- Hello, Meera!
- a tap event
- 4
- OFF
- 12
- handler
- True
- 1
- a timer event
- ON
- Well done, Kabir!
- a tap event
- Hello, Aman!
- 2
- ON
- a load event
- 2
- 2
- 10
- a load event
- an action
- True
- False
- 3
- Well done, Aman!
- OFF
- 32
- False
- Hi, Zoya!
- False
- True
Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students