Lua 5.0 introduced a major performance breakthrough by switching from a standard stack-based virtual machine to what specific type of Virtual Machine?
Register-based Virtual Machine (or Register-based VM)
What is the specific name of the mechanism (a table) used to define the behavior of other tables, enabling operator overloading and object-oriented inheritance?
Metatable
Lua was developed at PUC-Rio inside which specific Computer Graphics Technology Group?
Tecgraf
What specific compiler feature allows a Lua function to call itself indefinitely without causing a “Stack Overflow” error, provided the call is the final action?
Proper Tail Calls (or Tail Call Optimization / TCO)
By default, variables in Lua are global. What keyword must be used to explicitly declare a variable as lexically scoped to the current block?
Local
In Lua’s boolean evaluation, the number 0 and empty strings “” are considered false.
True or False
False (In Lua, 0 and “” are considered true. Only nil and false are false).
Lua strings are immutable, meaning once a string is created, it cannot be changed in place; a new string must be created for any modification.
True or False
True
Lua arrays (tables with integer keys) conventionally start at index 0, similar to C, Java, and Python.
True or False
False (Lua arrays conventionally start at index 1).
Lua supports multithreading by using native Operating System threads (like Pthreads or Windows threads) to execute code in parallel on multiple CPU cores.
True or False
False (Lua is single-threaded; it uses Coroutines for cooperative multitasking, not OS threads).
Variables in Lua are dynamically typed, meaning the variable itself has no type, only the value assigned to it has a type
True or False
True
Boolean Logic & Short-Circuiting What is the output of the following code?
local result = nil or "Moon" print(result)
LUA
“Moon” (The or operator returns the first truthy value. Since nil is false, it returns the second value).
Table Indexing Lua tables are sparse. What is the output of this code?
local t = { "A", "B", "C" }
print(t[0])LUA
nil (Lua is 1-based. Index 0 is not automatically created, so it is just an empty key returning nil).
Variable Scope (Shadowing) What value is printed at the end?
local x = 10 do local x = 20 x = x + 5 end print(x)
LUA
10 (The x inside the do…end block is a separate local variable that shadows the outer x. The outer x is untouched).
Data Type Coercion Lua automatically converts strings to numbers in arithmetic operations. What is the result?
print(“10”+5)
LUA
15 (Lua coerces strings to numbers when using arithmetic operators like +. Use .. for concatenation).
Control Flow (Loops) How many times will the string “Lua” be printed?
for i = 1, 3 do
print("Lua")
EndLUA
3 times (The for loop in Lua is inclusive of both the start and end points: 1, 2, and 3).