Exam With A+ Graded Answers 2025/2026.
1. What is the difference between a high-level language and a low-level language?
correct answer High-level languages (like Python or C#) are designed to be easily readable by
humans, using English-like syntax and abstracting away hardware details like memory
management. Low-level languages (like Assembly or Machine Code) provide little to no
abstraction from a computer's instruction set architecture, offering finer control over the
CPU but being much more difficult for humans to write and maintain.
2. Define a "Variable" and explain its role in computer programming.
correct answer A variable is a reserved memory location used to store a data value that can
be modified during program execution. It acts as a labeled container; the label (name) allows
the programmer to reference the data without needing to know the specific memory
address. Variables have "types" (like integers or strings) that determine what kind of data
they can hold and what operations can be performed on them.
3. Explain the concept of "Compilation" versus "Interpretation."
correct answer Compilation is the process where a compiler translates the entire source
code into machine code (an executable file) before the program runs, resulting in faster
execution. Interpretation is the process where an interpreter translates and executes the
code line-by-line at runtime. Compiled languages (like C++) are generally more efficient,
while interpreted languages (like Python) offer better cross-platform portability and easier
debugging.
4. What is an "Algorithm" and what makes one efficient?
correct answer An algorithm is a finite, step-by-step procedure for solving a specific problem
or performing a task. Efficiency is measured by "Big O Notation," which evaluates "Time
Complexity" (how fast it runs as data grows) and "Space Complexity" (how much memory it
uses). An efficient algorithm minimizes these resources, such as using a Binary Search instead
of a Linear Search for sorted data.
5. Describe the "Boolean" data type and its primary use.
correct answer The Boolean data type represents one of two possible values: True or False. It
is named after George Boole and is the foundation of computer logic. Booleans are primarily
used in "Conditional Statements" (like IF-ELSE) to control the flow of a program, allowing the
software to make decisions based on whether a specific condition is met or not.
6. What is a "String" and how is it stored in memory?
correct answer A string is a sequence of characters (letters, numbers, or symbols) used to
represent text. In memory, strings are typically stored as an array of bytes, where each
character is mapped to a numeric code using encoding standards like ASCII or Unicode (UTF-
8). Strings are often "immutable" in modern languages, meaning they cannot be changed
after they are created.
7. Explain the purpose of "Comments" in source code.
correct answer Comments are non-executable lines of text within a program intended for
human readers. They are used to explain the logic of complex code, document the purpose
of functions, or temporarily disable sections of code during testing. Proper commenting is a
, hallmark of professional software development, as it makes the codebase maintainable for
other engineers.
8. What is an "Integer" and how does it differ from a "Float"?
correct answer An integer is a whole number (positive, negative, or zero) without any
fractional or decimal component. A "Float" (floating-point number) is a data type used to
represent real numbers that require decimal precision. Because floats use a specific bit-
structure to store decimals, they can occasionally lead to rounding errors in complex
calculations, unlike integers which are always exact.
9. Define "Constant" and why a programmer might use one.
correct answer A constant is a type of identifier whose value cannot be altered during the
execution of a program once it has been set. Programmers use constants for values that
should remain fixed, such as the value of Pi, a tax rate, or a configuration setting. This
prevents accidental changes to critical data and makes the code easier to update in a single
location.
10. What is a "Syntax Error" and when does it occur?
correct answer A syntax error occurs when the code violates the grammatical rules of the
programming language (e.g., a missing parenthesis or a misspelled keyword). These errors
are detected by the compiler or interpreter before the program can run. Unlike "Logic
Errors," which allow the program to run but produce wrong results, a syntax error prevents
the program from executing entirely.
11. Explain the "IF-ELSE" conditional structure.
correct answer The IF-ELSE structure allows a program to execute different branches of code
based on a condition. If the condition evaluates to True, the code inside the "IF" block runs. If
it is False, the program skips that block and executes the code inside the "ELSE" block. This is
the most basic form of selection logic in programming.
12. What is a "Loop" and what are the two main types?
correct answer A loop is a control flow statement that allows a block of code to be repeated
multiple times. The two main types are "For Loops" and "While Loops." A "For Loop" is
typically used when the number of iterations is known in advance (e.g., iterating through a
list), whereas a "While Loop" repeats as long as a specific condition remains true.
13. Define an "Infinite Loop" and how to avoid one.
correct answer An infinite loop is a loop that never ends because its termination condition is
never met. This can cause a program to freeze or consume 100% of the CPU. To avoid this, a
programmer must ensure that the loop's "exit condition" is eventually satisfied—for
example, by incrementing a counter variable or using a break statement when a goal is
reached.
14. What is an "Array" (or List) and how are its elements accessed?
correct answer An array is an ordered collection of elements stored in contiguous memory.
Each element is accessed using an "Index," which represents its position in the collection. In
most programming languages, arrays are "Zero-Indexed," meaning the first element is at
index 0, the second at index 1, and so on.
15. Explain the concept of "Indexing" and "Slicing."
correct answer Indexing refers to selecting a single item from a collection by its position.