What is a runtime environment?
a) The phase during which the code is written
b) The environment where the program is executed
c) A debugging tool for developers
d) A type of compiler optimization
Answer: b) The environment where the program is executed
Which of the following is managed by the runtime environment?
a) Syntax checking
b) Memory allocation
c) Code compilation
d) Version control
Answer: b) Memory allocation
What is the primary role of a runtime environment in programming?
a) To compile the program
b) To provide services such as memory management and I/O handling
c) To debug the code
d) To write the program
Answer: b) To provide services such as memory management and I/O handling
Which of the following is a common feature of a runtime environment?
a) Static analysis
b) Execution of code
c) Source code formatting
d) Code optimization
Answer: b) Execution of code
In Java, what is the name of the runtime environment?
a) JVM (Java Virtual Machine)
b) JRE (Java Runtime Environment)
c) JDK (Java Development Kit)
d) SDK (Software Development Kit)
Answer: b) JRE (Java Runtime Environment)
What is “garbage collection” in a runtime environment?
a) A process of debugging code
b) Memory deallocation for objects no longer in use
c) Optimizing the runtime environment
d) Cleaning up syntax errors
Answer: b) Memory deallocation for objects no longer in use
Which of the following is typically not part of the runtime environment?
a) Memory management
b) Input/output handling
c) Compilation
d) Exception handling
Answer: c) Compilation
What is a “stack frame” in the runtime environment?
a) A section of memory for dynamic allocation
b) A data structure containing function call information
c) A storage area for global variables
d) A process for debugging runtime errors
Answer: b) A data structure containing function call information
In which memory segment does dynamic memory allocation take place during runtime?
a) Stack
b) Heap
c) Code segment
d) Data segment
Answer: b) Heap
Which of the following is a runtime error?
a) Syntax error
b) Segmentation fault
c) Undefined variable
d) Missing semicolon
Answer: b) Segmentation fault
Which runtime environment allows JavaScript to run outside the browser?
a) JRE
b) JVM
c) Node.js
d) Python interpreter
Answer: c) Node.js
Which part of the runtime environment handles function calls and local variables?
a) Stack
b) Heap
c) Global data section
d) Text segment
Answer: a) Stack
What happens to a program’s variables after the program terminates?
a) They remain in memory
b) They are deallocated and cleared from memory
c) They are saved to disk
d) They are transferred to the operating system
Answer: b) They are deallocated and cleared from memory
Which runtime error occurs when a program tries to access memory it doesn’t own?
a) Buffer overflow
b) Syntax error
c) Logic error
d) Memory leak
Answer: a) Buffer overflow
What is the role of the “runtime stack”?
a) It stores global variables
b) It tracks function calls and local variables
c) It manages dynamic memory allocation
d) It stores input/output operations
Answer: b) It tracks function calls and local variables
Which of the following errors can only be detected during runtime?
a) Type mismatch
b) Division by zero
c) Missing semicolon
d) Variable declaration
Answer: b) Division by zero
In which language runtime environment does garbage collection automatically manage memory?
a) C++
b) Java
c) C
d) Assembly
Answer: b) Java
Which of the following is a key difference between a compiled language and an interpreted language?
a) Compiled languages run in a runtime environment
b) Interpreted languages use a runtime environment for execution
c) Compiled languages do not use memory management
d) Interpreted languages cannot handle runtime errors
Answer: b) Interpreted languages use a runtime environment for execution
What is a “memory leak”?
a) A variable that is not properly initialized
b) Memory that is allocated but never freed
c) An error in syntax
d) A stack overflow issue
Answer: b) Memory that is allocated but never freed
Which of the following tools is a runtime environment for .NET applications?
a) JVM
b) CLR (Common Language Runtime)
c) Python interpreter
d) Node.js
Answer: b) CLR (Common Language Runtime)
What is a segmentation fault?
a) A syntax error in the program
b) Accessing restricted memory
c) Incorrect variable type declaration
d) A logic error in the program
Answer: b) Accessing restricted memory
What does “stack overflow” refer to in a runtime environment?
a) Insufficient memory in the heap
b) Running out of space in the runtime stack
c) Allocating too much memory in the global section
d) An error in the compiler
Answer: b) Running out of space in the runtime stack
In which runtime environment are Python scripts executed?
a) JVM
b) CLR
c) Python interpreter
d) Node.js
Answer: c) Python interpreter
What is the primary role of an interpreter in a runtime environment?
a) To optimize the code
b) To check for syntax errors
c) To execute code line by line
d) To generate machine code
Answer: c) To execute code line by line
Which of the following is not a runtime error?
a) Division by zero
b) Stack overflow
c) Type mismatch during compilation
d) Null pointer dereference
Answer: c) Type mismatch during compilation
What is the heap used for in the runtime environment?
a) Static memory allocation
b) Dynamic memory allocation
c) Storing function calls
d) Error handling
Answer: b) Dynamic memory allocation
Which runtime environment component handles object creation and destruction in Java?
a) Compiler
b) Garbage collector
c) Stack
d) File system
Answer: b) Garbage collector
What happens if a program runs out of memory in the heap?
a) It will generate a syntax error
b) It will cause a runtime error
c) The memory will be automatically freed
d) The program will continue running
Answer: b) It will cause a runtime error
Which runtime environment component tracks the sequence of function calls?
a) Heap
b) Stack
c) Data segment
d) Code segment
Answer: b) Stack
Which of the following is a benefit of using a virtual machine as a runtime environment?
a) Platform-specific execution
b) Cross-platform compatibility
c) Faster execution than native code
d) No need for memory management
Answer: b) Cross-platform compatibility
What is the purpose of an exception handler in a runtime environment?
a) To stop the program execution
b) To manage memory allocation
c) To deal with unexpected runtime errors
d) To optimize code execution
Answer: c) To deal with unexpected runtime errors
Which runtime error occurs when a program tries to divide a number by zero?
a) Null pointer exception
b) Arithmetic exception
c) Stack overflow
d) Segmentation fault
Answer: b) Arithmetic exception
What is the global data section used for in a runtime environment?
a) Storing dynamically allocated memory
b) Storing variables with global scope
c) Handling function calls
d) Storing temporary variables
Answer: b) Storing variables with global scope
Which of the following will cause a null pointer exception at runtime?
a) Calling a method on a null reference
b) Accessing an invalid array index
c) Dividing by zero
d) Infinite loop
Answer: a) Calling a method on a null reference
What happens during a runtime “stack unwind”?
a) The stack is cleared for memory management
b) Function calls are undone during exception handling
c) The heap is compacted
d) The global variables are reset
Answer: b) Function calls are undone during exception handling
In which memory section are local variables stored?
a) Heap
b) Stack
c) Code segment
d) Data segment
Answer: b) Stack
Which error can lead to memory corruption in a runtime environment?
a) Syntax error
b) Segmentation fault
c) Missing semicolon
d) Array index out of bounds
Answer: d) Array index out of bounds
Which component of a runtime environment is responsible for deallocating unused objects?
a) Compiler
b) Garbage collector
c) Stack pointer
d) Debugger
Answer: b) Garbage collector
What is the role of the text segment in a runtime environment?
a) It stores executable code
b) It stores global variables
c) It stores function call information
d) It manages dynamic memory allocation
Answer: a) It stores executable code
What is the consequence of a memory leak in a long-running application?
a) Syntax errors
b) Gradual memory exhaustion
c) Improved performance
d) Stack overflow
Answer: b) Gradual memory exhaustion
In which runtime environment does the CLR execute programs?
a) Java
b) .NET
c) Python
d) Node.js
Answer: b) .NET
Which of the following runtime errors is caused by accessing an invalid memory address?
a) Null pointer exception
b) Syntax error
c) Memory leak
d) Segmentation fault
Answer: d) Segmentation fault
Which runtime environment segment is responsible for static memory allocation?
a) Stack
b) Heap
c) Global data section
d) Code segment
Answer: c) Global data section
What does “Just-In-Time (JIT)” compilation refer to in a runtime environment?
a) Compilation before runtime
b) Compilation at runtime
c) Error handling
d) Memory management
Answer: b) Compilation at runtime
What causes a stack overflow error in a recursive function?
a) Infinite recursion
b) Incorrect variable declaration
c) Memory allocation in the heap
d) Code optimization
Answer: a) Infinite recursion
What is the primary responsibility of the runtime linker/loader?
a) Compiling the program
b) Linking library files during execution
c) Handling exceptions
d) Debugging the code
Answer: b) Linking library files during execution
Which type of memory is typically used for static variables in a runtime environment?
a) Heap
b) Stack
c) Data segment
d) Text segment
Answer: c) Data segment
In which runtime environment does the V8 engine execute JavaScript?
a) .NET
b) Node.js
c) JVM
d) Python interpreter
Answer: b) Node.js
Which of the following is responsible for cleaning up memory leaks?
a) Compiler
b) Runtime garbage collector
c) Debugger
d) Stack frame
Answer: b) Runtime garbage collector
What is a runtime exception in Java?
a) A compile-time error
b) An error detected during program execution
c) An error caused by incorrect syntax
d) A logical error in the code
Answer: b) An error detected during program execution