Practice Event in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

A detectable action or occurrence in a program—such as a user click, key press, mouse movement, or timer expiry—that the program can respond to by executing a predefined event handler function.

Something happens (click, keypress, timer) and the program reacts.

Showing a random 20 of 50 problems.

Example 1

easy
The function that runs in response to an event is called the event ____.

Example 2

easy
Name two examples of events a program might respond to.

Example 3

easy
A timer expires and triggers code. Is the timer expiry an event?

Example 4

medium
A 'double-click' is typically detected by: (a) the OS, (b) the application, or (c) either.

Example 5

medium
An event fires while the previous event's handler is still running. Where does it usually go?

Example 6

medium
A web app shows a tooltip on hover. List the events it must handle to show and hide the tooltip correctly.

Example 7

easy
In event-driven code, an event source is paired with a ____ that gets called when the event fires.

Example 8

medium
What is event bubbling?

Example 9

medium
In a multiplayer game, two players' actions arrive nearly simultaneously over the network. What ordering does the event queue impose?

Example 10

medium
A keypress handler must run only for the Enter key. Inside it you check the key. What programming structure does this require?

Example 11

easy
Is moving the mouse over an element an event?

Example 12

easy
Is a timer expiring (e.g., setTimeout firing) an event?

Example 13

medium
An event-driven simulation steps once per timer tick. After 4 ticks, the state update St+1=St+2S_{t+1}=S_t+2 starts at S0=1S_0=1. What is S4S_4?

Example 14

medium
Two handlers are bound to the same button click. How many times does the button's click event fire on one click, and how many handler calls occur?

Example 15

easy
If a click handler takes 5 seconds to run, what does the user experience?

Example 16

medium
True or false: in a typical browser, two click handlers cannot run at exactly the same moment.

Example 17

hard
A page has three buttons, each registered with the same click handler. Clicking any of them runs the handler. Inside the handler, what property of the event object tells you which button was clicked?

Example 18

medium
Identify the events in a 'sign in with password' form: typing in the email field, typing in the password field, clicking 'Sign in.'

Example 19

hard
What is an event source?

Example 20

medium
Why might attaching an event handler inside a loop that runs each frame cause a bug?