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.👆 A tap handler runs how many times if the user taps 4 times? (a) 8 (b) 0 (c) 1 (d) 4
-
2.👆 The user types Meera in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Welcome, " + nameBox.text + "!";
}; (a) Welcome! (b) Meera (c) Welcome, Meera! (d) Welcome, nameBox.text! -
3.👆 The user taps the button 2 times. What number does the label show now?
let points = 2;
button.onTap = function () {
points = points + 5;
label.text = points;
}; -
4.👆 The user taps the button 6 times. What number does the label show now?
let score = 10;
button.onTap = function () {
score = score + 3;
label.text = score;
}; - 5.👆 What kind of event is this: the screen first opens? (a) a tap event (b) a text event (c) a load event (d) a timer event
- 6.👆 Code that runs when an event happens is called a ___. (a) header (b) handler (c) hashtag (d) headline
-
7.👆 The user taps the button 4 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 - 8.👆 An event in an app is ___. (a) something that happens (b) a kind of list (c) an app store (d) a colour theme
-
9.👆 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) Hello, Aman! (b) Hello! (c) Hello, nameBox.text! (d) Aman - 10.True or false: the user presses Save is a tap event. (a) False (b) True
- 11.👆 What kind of event is this: the user types a letter? (a) a text event (b) a load event (c) a timer event (d) a tap event
-
12.👆 The user taps the button 3 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 3) {
likes = likes + 1;
}
label.text = likes;
}; - 13.True or false: the screen first opens is a load event. (a) True (b) False
- 14.👆 What kind of event is this: a countdown hits zero? (a) a load event (b) a text event (c) a tap event (d) a timer event
- 15.True or false: the user taps Play is a text event. (a) False (b) True
- 16.True or false: a countdown hits zero is a load event. (a) True (b) False
-
17.👆 The user taps the button 6 times. What number does the label show now?
let points = 5;
button.onTap = function () {
points = points + 3;
label.text = points;
}; -
18.👆 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) OFF (b) ON - 19.👆 What kind of event is this: the search box changes? (a) a timer event (b) a tap event (c) a load event (d) a text event
- 20.👆 “On tap → do this” links an event to ___. (a) a charger (b) an action (c) a web address (d) a font
- 21.True or false: one second passes is a load event. (a) False (b) True
-
22.👆 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) Hi, nameBox.text! (b) Hi! (c) Hi, Riya! (d) Riya -
23.👆 The user taps the button 8 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 5) {
likes = likes + 1;
}
label.text = likes;
}; - 24.True or false: a 5-minute alarm ends is a timer event. (a) False (b) True
-
25.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hi, " + nameBox.text + "!";
}; (a) Hi, Aman! (b) Hi! (c) Hi, nameBox.text! (d) Aman - 26.True or false: a countdown hits zero is a text event. (a) False (b) True
- 27.👆 What kind of event is this: the user taps Play? (a) a load event (b) a text event (c) a timer event (d) a tap event
- 28.👆 Which of these is an event? (a) a list of names (b) the user taps a button (c) the font size (d) the icon colour
-
29.👆 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! (b) Aman (c) Welcome, nameBox.text! (d) Welcome, Aman! - 30.True or false: the screen first opens is a text event. (a) False (b) True
- 31.True or false: the search box changes is a text event. (a) True (b) False
-
32.👆 The user taps the button 2 times. What number does the label show now?
let points = 7;
button.onTap = function () {
points = points + 1;
label.text = points;
}; - 33.True or false: the user taps Play is a timer event. (a) True (b) False
- 34.👆 What kind of event is this: a finger hits Like? (a) a text event (b) a load event (c) a timer event (d) a tap event
- 35.True or false: the app starts up is a tap event. (a) True (b) False
-
36.👆 The user taps the button 5 times. What number does the label show now?
let stars = 5;
button.onTap = function () {
stars = stars + 1;
label.text = stars;
}; -
37.👆 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 -
38.👆 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;
}; -
39.👆 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;
}; -
40.👆 The user types Riya in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hello, " + nameBox.text + "!";
}; (a) Hello, nameBox.text! (b) Hello, Riya! (c) Hello! (d) Riya
Answer key
- 4
- Welcome, Meera!
- 12
- 28
- a load event
- handler
- OFF
- something that happens
- Hello, Aman!
- True
- a text event
- 3
- True
- a timer event
- False
- False
- 23
- OFF
- a text event
- an action
- False
- Hi, Riya!
- 5
- True
- Hi, Aman!
- False
- a tap event
- the user taps a button
- Welcome, Aman!
- False
- True
- 9
- False
- a tap event
- False
- 10
- OFF
- 1
- 1
- Hello, Riya!
Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students