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
easyThe function that runs in response to an event is called the event ____.
Example 2
easyName two examples of events a program might respond to.
Example 3
easyA timer expires and triggers code. Is the timer expiry an event?
Example 4
mediumA 'double-click' is typically detected by: (a) the OS, (b) the application, or (c) either.
Example 5
mediumAn event fires while the previous event's handler is still running. Where does it usually go?
Example 6
mediumA web app shows a tooltip on hover. List the events it must handle to show and hide the tooltip correctly.
Example 7
easyIn event-driven code, an event source is paired with a ____ that gets called when the event fires.
Example 8
mediumWhat is event bubbling?
Example 9
mediumIn a multiplayer game, two players' actions arrive nearly simultaneously over the network. What ordering does the event queue impose?
Example 10
mediumA keypress handler must run only for the Enter key. Inside it you check the key. What programming structure does this require?
Example 11
easyIs moving the mouse over an element an event?
Example 12
easyIs a timer expiring (e.g., setTimeout firing) an event?
Example 13
mediumAn event-driven simulation steps once per timer tick. After 4 ticks, the state update starts at . What is ?
Example 14
mediumTwo 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
easyIf a click handler takes 5 seconds to run, what does the user experience?
Example 16
mediumTrue or false: in a typical browser, two click handlers cannot run at exactly the same moment.
Example 17
hardA 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
mediumIdentify the events in a 'sign in with password' form: typing in the email field, typing in the password field, clicking 'Sign in.'
Example 19
hardWhat is an event source?
Example 20
mediumWhy might attaching an event handler inside a loop that runs each frame cause a bug?