


















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















































































Question 1. Which term best describes a set of instructions that a computer can execute to solve a problem? A) Compiler B) Algorithm C) Program D) Debugger Answer: C Explanation: A program is the concrete implementation of an algorithm written in a programming language that a computer can execute. Question 2. In high‑level languages, which component translates source code into machine code before execution? A) Interpreter B) Assembler C) Compiler D) Linker Answer: C Explanation: A compiler converts the entire source code into machine code (object code) prior to running the program. Question 3. Which of the following is a characteristic of a low‑level language? A) Platform independence B) Human‑readable syntax C) Direct hardware manipulation D) Automatic memory management
Answer: C Explanation: Low‑level languages, such as assembly, allow programmers to work closely with hardware resources. Question 4. An IDE typically provides all of the following EXCEPT: A) Code editor with syntax highlighting B) Integrated debugger C) Automatic code generation for any algorithm D) Build and run tools Answer: C Explanation: IDEs assist development but do not magically generate correct code for arbitrary algorithms. Question 5. What is the purpose of a comment in source code? A) To increase execution speed B) To provide documentation for human readers C) To define a variable type D) To allocate memory Answer: B Explanation: Comments are ignored by the compiler/interpreter and serve only to explain code to developers. Question 6. Which data type is most appropriate for storing the value 3.14159? A) Integer B) Boolean
D) None of the above Answer: B Explanation: Multiplication (*) is evaluated before addition (+) according to standard operator precedence rules. Question 10. Which relational operator tests for inequality? A) == B) != C) >= D) < Answer: B Explanation: The != operator returns true when the two operands are not equal. Question 11. The logical expression !(true && false) evaluates to: A) true B) false C) true && false D) Syntax error Answer: A Explanation: true && false is false; applying NOT (!) yields true. Question 12. In the statement if (score >= 50), what type of operator is >=?
A) Arithmetic B) Assignment C) Relational D) Logical Answer: C Explanation: >= compares two values and returns a Boolean result, making it a relational operator. Question 13. Which construct allows a program to choose between two mutually exclusive blocks of code? A) FOR loop B) WHILE loop C) IF…ELSE statement D) SWITCH statement Answer: C Explanation: An IF…ELSE statement executes one block if the condition is true, otherwise the alternative block. Question 14. A nested IF statement is useful when: A) You need to repeat code a fixed number of times B) You have multiple independent conditions C) One condition depends on the result of another condition D) You want to exit a loop early Answer: C Explanation: Nesting allows a second IF to be evaluated only when the outer IF’s condition is true.
Explanation: Syntax errors are detected by the compiler/interpreter because the code does not conform to language syntax. Question 18. When a program attempts to divide by zero, the error is classified as: A) Syntax error B) Logic error C) Run‑time error D) Semantic error Answer: C Explanation: Division by zero is detected only when the program runs, making it a run‑time error. Question 19. In pseudocode, which symbol typically represents a decision point? A) Rectangle B) Diamond C) Oval D) Parallelogram Answer: B Explanation: A diamond shape in flowcharts (and its textual equivalent in pseudocode) denotes a decision/branch. Question 20. Which of the following is NOT a step in the typical software development life cycle? A) Requirement analysis B) Compilation C) Testing
D) Maintenance Answer: B Explanation: Compilation is a technical activity within development, not a distinct life‑cycle phase. Question 21. The process of breaking a large problem into smaller sub‑problems is called: A) Integration B) Encapsulation C) Decomposition D) Refactoring Answer: C Explanation: Decomposition improves manageability by dividing a complex task into simpler units. Question 22. A function differs from a procedure because a function: A) Cannot accept parameters B) Must return a value C) Executes without a call statement D) Is defined outside the program Answer: B Explanation: Functions are designed to compute and return a value, whereas procedures may perform actions without returning data. Question 23. Which method of passing arguments allows the called subroutine to modify the original variable? A) Pass‑by‑value
Question 26. Which of the following is a Boolean literal in most programming languages? A) 0 B) "false" C) true D) None of the above Answer: C Explanation: true (and false) are Boolean literals representing logical truth values. Question 27. In a flowchart, which symbol indicates the start or end of a process? A) Rectangle B) Diamond C) Oval D) Parallelogram Answer: C Explanation: Ovals (or rounded rectangles) denote terminal points such as Start and End. Question 28. Which of the following best describes an interpreter? A) Converts source code to machine code once, then runs it repeatedly B) Translates each line of source code to machine code at execution time C) Optimizes code for faster execution before running D) Links multiple compiled modules together Answer: B Explanation: An interpreter reads and executes source code line‑by‑line, performing translation on the fly.
Question 29. What is the primary advantage of using a high‑level language over assembly? A) Faster execution speed B) Direct hardware access C) Greater portability across platforms D. Smaller binary size Answer: C Explanation: High‑level languages abstract hardware details, making programs easier to move between different systems. Question 30. Which operator is used to obtain the remainder of integer division? A) / B) % C) // D) * Answer: B Explanation: The modulo operator (%) returns the remainder after division. Question 31. In most languages, which of the following statements correctly declares a constant named MAX_USERS with value 100? A) const int MAX_USERS = 100; B) int MAX_USERS = const 100; C) #define MAX_USERS 100 D) Both A and C are valid
Answer: D Explanation: == is a relational (equality) operator, not a logical operator. Question 35. In a FOR loop, the loop variable is typically updated: A) At the start of each iteration B) At the end of each iteration automatically C) Only when a break occurs D) By the programmer inside the loop body Answer: B Explanation: Most FOR constructs automatically increment or decrement the loop variable after each iteration. Question 36. Which statement about arrays is true? A) All elements must be of different data types B) The size of an array can be changed at run time in static languages C) Array indices are always positive integers D) Arrays can store functions directly Answer: C Explanation: Array indices are non‑negative integers; the other statements are generally false. Question 37. Which of the following best illustrates operator associativity? A) a + b * c
B) a = b = c C) a < b && b < c D) a % b % c Answer: B Explanation: The assignment operator (=) is right‑associative, so a = b = c assigns c to b then to a. Question 38. What is the result of the expression 5 + 2 * 3 == 11? A) 5 B) 11 C) true D) false Answer: C Explanation: Multiplication first: 2*3=6; then addition: 5+6=11; comparison == 11 yields true. Question 39. Which loop guarantees that its body executes at least once? A) FOR loop B) WHILE loop C) DO‑WHILE loop D) FOREACH loop Answer: C Explanation: A DO‑WHILE evaluates the condition after executing the loop body, ensuring one execution. Question 40. In modular programming, what is the purpose of a header file?
Question 43. What is the purpose of a “case” or “switch” statement? A) To iterate over a collection B) To select one of many code blocks based on a variable’s value C) To define a new data type D) To handle exceptions Answer: B Explanation: Switch statements evaluate an expression and jump to the matching case block. Question 44. Which of the following best defines “encapsulation” in object‑oriented concepts (though only basic awareness is required at Level 2)? A) Hiding internal data and exposing only necessary operations B) Inheriting properties from another class C) Defining multiple functions with the same name D) Running multiple threads simultaneously Answer: A Explanation: Encapsulation bundles data with methods and restricts direct access, protecting integrity. Question 45. In pseudocode, which keyword typically indicates the start of a loop that repeats while a condition is true? A) REPEAT UNTIL B) WHILE C) FOR D) DO
Answer: B Explanation: WHILE begins a condition‑controlled loop that continues as long as the condition holds. Question 46. Which of the following is the correct way to comment a single line in most C‑style languages? A) // This is a comment B) * This is a comment * C) # This is a comment D) Answer: A Explanation: // starts a single‑line comment in C, C++, Java, JavaScript, etc. Question 47. When a variable is declared but not initialized, its value is: A) Always zero B) Undefined (contains garbage) C) Null D) The string “undefined” Answer: B Explanation: Uninitialized variables contain whatever bits happen to be in memory, leading to undefined behavior. Question 48. Which of the following best describes “type casting”? A) Changing a variable’s name B) Converting a value from one data type to another
B) Improved readability C) Increased compilation time D) Easier testing Answer: C Explanation: Functions generally reduce, not increase, compilation time; they aid reuse, readability, and testing. Question 52. When a program needs to store a true/false value, which data type should be used? A) Integer B) Char C) Boolean D) Float Answer: C Explanation: Boolean types are designed specifically for true/false logical values. Question 53. Which of the following best explains “operator precedence”? A) The order in which operators are written in the source file B) The hierarchy that determines which operators are evaluated first in an expression C) The speed at which an operator executes D) The number of operands an operator takes Answer: B Explanation: Precedence rules dictate evaluation order, e.g., multiplication before addition. Question 54. In a WHILE loop, the condition is evaluated:
A) Before the first iteration only B) After each iteration only C) Before each iteration D) Never, it is assumed true Answer: C Explanation: WHILE checks its condition prior to each execution of the loop body. Question 55. Which of the following is a correct way to declare an array of 10 integers in most C‑style languages? A) int[10] numbers; B) int numbers[10]; C) array int numbers = 10; D) int numbers = new int[10]; Answer: B Explanation: int numbers[10]; declares an integer array with ten elements. Question 56. Which of the following best describes a “syntax error”? A) The program produces the wrong answer B) The program crashes during execution C) The compiler reports an error because the code does not follow language rules D) The algorithm is inefficient Answer: C Explanation: Syntax errors are detected at compile time when the source violates grammatical rules.