Online Coding Lessons Practice Test ā Questions and Answers
Question 1: Which C++ concept lets two functions share a name but differ by parameter list?
- Templating
- Overloading (Correct answer)
- Overriding
- Inheriting
Correct answer: Overloading
Function overloading allows multiple functions with the same name but different signatures.
Question 2: Which sorting algorithm works by repeatedly swapping adjacent elements if they are in the wrong order?
- Quick Sort
- Insertion Sort
- Merge Sort
- Bubble Sort (Correct answer)
Correct answer: Bubble Sort
Bubble Sort works by repeatedly comparing and swapping adjacent elements until the list is sorted, causing larger values to 'bubble' to the end.
Question 3: What does 'index' mean in the context of an array?
- The value stored in the array
- The position of an element within the array (Correct answer)
- The total number of elements
- The type of data stored
Correct answer: The position of an element within the array
An index is a numerical position used to access a specific element in an array, typically starting from 0.
Question 4: What is a 'level editor' in game development?
- A tool for editing game audio
- A code debugger for game scripts
- A software tool that allows designers to visually create and arrange game levels (Correct answer)
- A tool for adjusting game difficulty
Correct answer: A software tool that allows designers to visually create and arrange game levels
A level editor is a visual tool that allows game developers and designers to create, arrange, and test game levels without writing complex code.
Question 5: What is 'pixel art' commonly used for in game development?
- Creating retro-style low-resolution 2D game graphics (Correct answer)
- Testing game performance
- Debugging visual glitches
- Creating 3D character models
Correct answer: Creating retro-style low-resolution 2D game graphics
Pixel art is a digital art style where images are created at the pixel level, commonly used in indie and retro-style 2D games to create a classic aesthetic.
Question 6: What is Pygame?
- A Python library for creating 2D games and multimedia applications (Correct answer)
- A game development platform for Android
- A game design tool for children
- A 3D game engine for professionals
Correct answer: A Python library for creating 2D games and multimedia applications
Pygame is a set of Python modules designed for writing 2D video games, providing tools for graphics, sound, and user input handling.
Question 7: What does 'NPC' stand for in game development?
- Numeric Processing Code
- Network Protocol Controller
- New Pixel Component
- Non-Player Character (Correct answer)
Correct answer: Non-Player Character
NPC stands for Non-Player Character, referring to characters in a game that are controlled by the computer's AI rather than a human player.
Question 8: What is a game engine?
- Software that provides tools and frameworks for building video games (Correct answer)
- The graphics card in a computer
- The processor inside a gaming console
- The network server for online games
Correct answer: Software that provides tools and frameworks for building video games
A game engine is a software framework that provides common game development tools ā like rendering, physics, and audio ā so developers don't build everything from scratch.
Question 9: Which C++ keyword is used to prevent a member function from modifying the object's state?
- mutable
- volatile
- static
- const (Correct answer)
Correct answer: const
Marking a member function const guarantees it will not modify the object's members.
Question 10: In C++, which header provides std::cout and std::cin?
- <stdio.h>
- <string>
- <iostream> (Correct answer)
- <fstream>
Correct answer: <iostream>
<iostream> declares the standard stream objects std::cout and std::cin.
Question 11: What does 'open world' mean in game design?
- A multiplayer online game
- A game with no storyline
- A game with an online leaderboard
- A game design where players can freely explore a large environment without linear restrictions (Correct answer)
Correct answer: A game design where players can freely explore a large environment without linear restrictions
An open world game design gives players the freedom to explore a large virtual environment and complete objectives in any order, rather than following a strictly linear path.
Question 12: Which data type is used to store a sequence of characters in Python?
- list
- bool
- int
- str (Correct answer)
Correct answer: str
The 'str' (string) data type in Python is used to store sequences of characters.
Question 13: If an is an integer variable, a=7/3; will yield a result of
- 2 (Correct answer)
- 2.53
- 0
- 3
Correct answer: 2
When performing integer division in many programming languages (like C, C++, or Java), if both operands are integers, the result will also be an integer, and any fractional part is truncated. For `a = 7 / 3;`, the mathematical result is approximately 2.33. Since `a` is an integer variable, the `.33` is discarded, yielding `2`.
Question 14: What CSS property controls the size of text?
- font-size (Correct answer)
- text-style
- font-height
- text-size
Correct answer: font-size
The 'font-size' CSS property sets the size of text, which can be specified in pixels, ems, rems, or percentages.
Question 15: What is a 'hitbox' in game development?
- A container for game assets
- The area around a boss enemy
- A box that spawns health items
- An invisible boundary used to detect collisions around a game object (Correct answer)
Correct answer: An invisible boundary used to detect collisions around a game object
A hitbox is an invisible geometric shape placed around a game object to define the area where collisions or interactions can be detected.
Question 16: Which data structure is best suited for implementing a 'back' button in a browser?
- Queue
- Stack (Correct answer)
- Array
- Linked List
Correct answer: Stack
A stack is ideal for a browser's back button because visited pages are added to the top, and clicking 'back' pops the most recent page off the stack (LIFO).
Question 17: Which popular game engine uses C# as its primary scripting language?
- Unity (Correct answer)
- Unreal Engine
- GameMaker
- Godot
Correct answer: Unity
Unity primarily uses C# as its scripting language, making it one of the most widely used game engines for 2D and 3D games.
Question 18: What is 'pathfinding' in game AI?
- Finding and fixing bugs in game code
- A technique for loading game assets
- A method for drawing paths in a racing game
- The algorithm that determines how NPCs navigate from one point to another (Correct answer)
Correct answer: The algorithm that determines how NPCs navigate from one point to another
Pathfinding algorithms (like A*) are used in game AI to calculate the optimal route for NPCs to travel from one location to another while avoiding obstacles.
Question 19: In C, what is the value of an array name when used in most expressions?
- The first element's value
- A copy of the array
- A pointer to the first element (Correct answer)
- The array size
Correct answer: A pointer to the first element
An array name decays to a pointer to its first element in most contexts.
Question 20: What goes inside the parentheses when you create a function?
- Parameters (inputs) (Correct answer)
- A picture
- The page title
- The date
Correct answer: Parameters (inputs)
Parameters are the inputs a function can use when it runs.
Question 21: The allowable range for integer constants in a 16-bit compiler is __________.
- -32768 to 32767 (Correct answer)
- -32668 to 32667
- -32767 to 32768
- -3.4e38 to 3.4e38
Correct answer: -32768 to 32767
A 16-bit signed integer uses one bit for the sign and 15 bits for the magnitude of the number. This allows it to represent 2^15 positive values (0 to 32767) and 2^15 negative values (-1 to -32768). Therefore, the standard range for a 16-bit signed integer is from -32768 to 32767.
Question 22: In C++, which container provides automatic dynamic resizing and contiguous storage?
- std::set
- std::map
- std::vector (Correct answer)
- std::list
Correct answer: std::vector
std::vector stores elements contiguously and grows automatically as needed.
Question 23: What is 'divide and conquer' as a programming strategy?
- Breaking a problem into smaller subproblems, solving them, and combining results (Correct answer)
- A method of sorting by dividing an array in half
- Using two nested loops
- Splitting code into multiple files
Correct answer: Breaking a problem into smaller subproblems, solving them, and combining results
Divide and conquer is an algorithm design strategy that breaks a problem into smaller subproblems, solves each one recursively, and combines the results.
Question 24: What is a tree data structure?
- A circular linked list
- A list of elements in sorted order
- A hash table with keys
- A hierarchical structure with a root node and child nodes (Correct answer)
Correct answer: A hierarchical structure with a root node and child nodes
A tree is a non-linear hierarchical data structure with a root node at the top and child nodes branching below it.
Question 25: Which CSS property is used to change the background color of an element?
- fill
- background-color (Correct answer)
- color
- bg-color
Correct answer: background-color
The 'background-color' CSS property sets the background color of an HTML element.
Question 26: What is 'delta time' used for in game programming?
- Calculating the time to beat a level
- Making game movement consistent regardless of frame rate (Correct answer)
- Tracking player score changes
- Measuring the frame rate of a game
Correct answer: Making game movement consistent regardless of frame rate
Delta time is the time elapsed since the last frame, used to ensure game movement and physics are consistent regardless of how fast or slow the game runs.
Question 27: What does 'O(1)' mean in Big O notation?
- The algorithm takes n steps
- The algorithm takes no time
- The algorithm uses one byte of memory
- The algorithm has constant time complexity regardless of input size (Correct answer)
Correct answer: The algorithm has constant time complexity regardless of input size
O(1) means constant time complexity ā the algorithm takes the same amount of time regardless of how large the input is.
Question 28: In a database table, what is a primary key?
- The most important data in a row
- A password that locks the table
- The first column in every table
- A column that uniquely identifies each row (Correct answer)
Correct answer: A column that uniquely identifies each row
A primary key is a column (or combination of columns) whose values uniquely identify every row in a table.
Question 29: Which of the following does NOT qualify as a logical or relational operator?
- != (Correct answer)
- ==
- =
- ||
Correct answer: !=
The `!=` operator (read as 'not equal to') is a relational operator used to compare two values. It evaluates to `true` if the operands are different, and `false` if they are the same. This comparison determines a relationship between the values, making it a key component in conditional statements for checking inequality.
Question 30: In C, what does the sizeof operator return for an int on most modern 64-bit systems?
- 2 bytes
- 8 bytes
- 1 byte
- 4 bytes (Correct answer)
Correct answer: 4 bytes
An int is typically 4 bytes on most modern platforms regardless of 32- or 64-bit.
Question 31: What keyword is used in SQL to filter rows returned by a SELECT query?
- FILTER
- WHERE (Correct answer)
- LIMIT
- HAVING
Correct answer: WHERE
The WHERE clause is used to specify conditions that rows must meet to be included in the query results.
Question 32: What is the time complexity of a linear search algorithm?
- O(log n)
- O(n) (Correct answer)
- O(n²)
- O(1)
Correct answer: O(n)
Linear search has O(n) time complexity because in the worst case, it must check every element in the list once.
Question 33: What is Unreal Engine best known for?
- High-fidelity 3D graphics and AAA game production (Correct answer)
- Web browser games
- Educational coding for children
- Simple 2D mobile games
Correct answer: High-fidelity 3D graphics and AAA game production
Unreal Engine, developed by Epic Games, is renowned for its high-quality 3D visuals and is widely used in AAA game titles and film production.
Question 34: What is recursion in programming?
- A loop that runs exactly 10 times
- A method for searching data
- A type of array sorting
- A function that calls itself to solve a smaller version of the same problem (Correct answer)
Correct answer: A function that calls itself to solve a smaller version of the same problem
Recursion is a programming technique where a function calls itself with a modified input to solve a problem by breaking it into smaller subproblems.
Question 35: What is a 'loop' used for in Scratch?
- To play music
- To change a sprite's costume
- To repeat a set of blocks multiple times (Correct answer)
- To stop a script
Correct answer: To repeat a set of blocks multiple times
A loop in Scratch (like 'repeat' or 'forever') is used to execute a set of blocks multiple times without writing them out repeatedly.
Question 36: What is the correct format specifier to print a floating-point double with printf in C?
- %f (Correct answer)
- %s
- %d
- %c
Correct answer: %f
%f is used to print float and double values with printf.
Question 37: What is Xcode used for?
- Apple's integrated development environment (IDE) for iOS and macOS app development (Correct answer)
- Developing Android apps
- A cross-platform game engine
- A cloud hosting platform
Correct answer: Apple's integrated development environment (IDE) for iOS and macOS app development
Xcode is Apple's official IDE used to write, debug, and deploy iOS, macOS, and other Apple platform applications.
Question 38: In C++, what does the 'new' operator do that 'malloc' does not?
- Calls the object's constructor (Correct answer)
- Returns void*
- Never throws
- Allocates on the stack
Correct answer: Calls the object's constructor
new allocates memory and invokes the constructor, while malloc only allocates raw bytes.
Question 39: What is a function in JavaScript?
- A type of color
- A web browser
- A keyboard key
- A reusable block of code (Correct answer)
Correct answer: A reusable block of code
A function groups code so you can run it again and again.
Question 40: What is 'collision detection' in game development?
- Detecting game crashes
- Determining when two game objects physically overlap or touch (Correct answer)
- Detecting network lag
- Finding bugs in game code
Correct answer: Determining when two game objects physically overlap or touch
Collision detection is the computational process of determining when two or more game objects intersect or touch, which is crucial for gameplay interactions.
Question 41: What is a linked list?
- A tree with two branches
- A data structure where each node points to the next node (Correct answer)
- An array with a fixed size
- A sorted array
Correct answer: A data structure where each node points to the next node
A linked list is a data structure where each element (node) contains data and a pointer/reference to the next node in the sequence.
Question 42: Which HTML tag is used to define an unordered (bulleted) list?
- <li>
- <ol>
- <ul> (Correct answer)
- <list>
Correct answer: <ul>
The <ul> tag defines an unordered list with bullet points, while each item is wrapped in <li> tags.
Question 43: Which loop is best for repeating an action a set number of times, like 10 times?
- comment
- for loop (Correct answer)
- function
- if statement
Correct answer: for loop
A for loop repeats code a chosen number of times.
Question 44: What is a 'deque' (double-ended queue)?
- A queue that can only add elements at one end
- A binary tree structure
- A sorted stack
- A data structure where elements can be added or removed from both ends (Correct answer)
Correct answer: A data structure where elements can be added or removed from both ends
A deque (double-ended queue) is a data structure that allows insertion and deletion of elements from both the front and the back.
Question 45: Which CSS property is used to change the text color?
- font-color
- text-color
- foreground
- color (Correct answer)
Correct answer: color
The CSS 'color' property is used to set the color of text content in an element.
Question 46: What is Flutter?
- A database for mobile apps
- An iOS-only design tool
- Google's cross-platform UI framework using Dart (Correct answer)
- A JavaScript testing tool
Correct answer: Google's cross-platform UI framework using Dart
Flutter is Google's open-source UI framework that uses the Dart programming language to build natively compiled apps for mobile, web, and desktop from a single codebase.
Question 47: Which clause in SQL is used to filter groups after a GROUP BY, similar to how WHERE filters rows?
- HAVING (Correct answer)
- WHERE
- GROUPWHERE
- FILTER
Correct answer: HAVING
The HAVING clause filters groups created by GROUP BY based on aggregate conditions, while WHERE filters individual rows before grouping.
Question 48: In C++, what does the 'virtual' keyword enable for a base class function?
- Compile-time binding
- Inline expansion
- Runtime polymorphism via dynamic dispatch (Correct answer)
- Constant evaluation
Correct answer: Runtime polymorphism via dynamic dispatch
virtual functions are resolved at runtime, enabling polymorphic behavior through base pointers.
Question 49: What is the purpose of the 'break' statement inside a C switch block?
- Return from the function
- Restart the switch
- Skip to the next case
- Exit the switch to prevent fall-through (Correct answer)
Correct answer: Exit the switch to prevent fall-through
break exits the switch so execution does not fall through into later cases.
Question 50: What is the worst-case time complexity of Bubble Sort?
- O(n)
- O(log n)
- O(n log n)
- O(n²) (Correct answer)
Correct answer: O(n²)
Bubble Sort has a worst-case time complexity of O(n²) because it may need to compare every element with every other element.
Question 51: What is a 'sprite' in 2D game development?
- A collision detection method
- A 2D image or animation used to represent characters or objects in a game (Correct answer)
- A background soundtrack
- A type of programming loop
Correct answer: A 2D image or animation used to represent characters or objects in a game
In 2D game development, a sprite is a 2D bitmap image or animation used to represent game characters, items, and other visual elements.
Question 52: Which of the following is a scripting language commonly used in Roblox game development?
- Python
- C#
- Lua (Correct answer)
- JavaScript
Correct answer: Lua
Roblox uses Luau (a dialect of Lua) as its primary scripting language for creating games and interactive experiences on its platform.
Question 53: What does 'procedural generation' mean in game design?
- Following step-by-step development procedures
- A testing methodology for games
- Algorithmically creating content (levels, terrain) at runtime rather than manually designing it (Correct answer)
- Writing procedural code in C++
Correct answer: Algorithmically creating content (levels, terrain) at runtime rather than manually designing it
Procedural generation is a technique that uses algorithms to automatically create game content ā like levels, worlds, or items ā often resulting in unique experiences each playthrough.
Question 54: What does the C function strlen return for the string "hello"?
- 0
- 4
- 6
- 5 (Correct answer)
Correct answer: 5
strlen counts characters up to but not including the null terminator, giving 5.
Question 55: What happens if you call free() twice on the same C pointer?
- Nothing harmful
- It returns NULL
- Undefined behavior (Correct answer)
- The memory is doubled
Correct answer: Undefined behavior
A double free results in undefined behavior and can corrupt the heap.
Question 56: What is the purpose of a graph data structure?
- Displaying chart data on a screen
- Representing relationships between objects using nodes and edges (Correct answer)
- Sorting elements in order
- Storing hierarchical data
Correct answer: Representing relationships between objects using nodes and edges
A graph is a data structure that represents relationships between objects using nodes (vertices) connected by edges, modeling networks and connections.
Question 57: What is a stack data structure?
- A structure where elements are added and removed from the front
- A structure where elements follow Last-In-First-Out (LIFO) order (Correct answer)
- A collection of key-value pairs
- A sorted list of elements
Correct answer: A structure where elements follow Last-In-First-Out (LIFO) order
A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle, where the last element added is the first to be removed.
Question 58: What is a hash table?
- A data structure that maps keys to values using a hash function (Correct answer)
- A sorted list of numbers
- A table used in HTML
- A type of binary tree
Correct answer: A data structure that maps keys to values using a hash function
A hash table is a data structure that uses a hash function to map keys to their associated values, allowing for fast lookup operations.
Question 59: What is the main advantage of binary search over linear search?
- It is faster, with O(log n) complexity on sorted arrays (Correct answer)
- It uses less memory
- It works on unsorted arrays
- It works on strings only
Correct answer: It is faster, with O(log n) complexity on sorted arrays
Binary search has O(log n) time complexity on sorted arrays, making it much faster than linear search's O(n) for large datasets.
Question 60: In SQL, what does the wildcard character % represent when used with the LIKE operator?
- Exactly one character
- A literal percent sign only
- Any sequence of zero or more characters (Correct answer)
- Any single digit
Correct answer: Any sequence of zero or more characters
The % wildcard in a LIKE pattern matches any sequence of zero or more characters, making it useful for partial-text searches.
Online Coding Lessons Practice Test
Assesses foundational and applied coding skills across programming fundamentals, data structures and algorithms, game development, and mobile app development using languages such as C, C++, Python, and JavaScript.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong ā answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds