Docsity

D278 SCRIPTING AND PROGRAMMING FOUNDATIONS 2026/2027 EXAM – 125 STUDY GUIDE, Exams of Computer Science

Toggle sidebar
bg1
1
D278 SCRIPTING AND PROGRAMMING FOUNDATIONS
2026/2027 EXAM – 125 STUDY GUIDE – PRACTICE QUESTIONS
WITH DETAILED RATIONALES (LATEST EDITION)
Computer Science (Programming Fundamentals & Scripting)
Exam Summary:
• Section 1 (Q1–25): Programming Paradigms & Language
Types
• Section 2 (Q26–50): Core Programming Concepts
(Variables, Data Types, Operators)
• Section 3 (Q51–75): Control Structures (Conditionals &
Loops)
• Section 4 (Q76–100): Functions, Modularization &
Recursion
• Section 5 (Q101–125): Data Structures, File I/O &
Debugging
1. A development team is choosing a language for a new
project that requires high performance and direct hardware
interaction. The team lead explains that the language will
be translated entirely into machine code before execution,
resulting in a standalone executable file. Which type of
language is the team lead describing?
A. An interpreted language
B. A compiled language
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download D278 SCRIPTING AND PROGRAMMING FOUNDATIONS 2026/2027 EXAM – 125 STUDY GUIDE and more Exams Computer Science in PDF only on Docsity!

D278 SCRIPTING AND PROGRAMMING FOUNDATIONS

2026/2027 EXAM – 125 STUDY GUIDE – PRACTICE QUESTIONS

WITH DETAILED RATIONALES (LATEST EDITION)

Computer Science (Programming Fundamentals & Scripting) Exam Summary:

  • Section 1 (Q1–25): Programming Paradigms & Language Types
  • Section 2 (Q26–50): Core Programming Concepts (Variables, Data Types, Operators)
  • Section 3 (Q51–75): Control Structures (Conditionals & Loops)
  • Section 4 (Q76–100): Functions, Modularization & Recursion
  • Section 5 (Q101–125): Data Structures, File I/O & Debugging
  1. A development team is choosing a language for a new project that requires high performance and direct hardware interaction. The team lead explains that the language will be translated entirely into machine code before execution, resulting in a standalone executable file. Which type of language is the team lead describing? A. An interpreted language B. A compiled language

C. A markup language D. A scripting language CORRECT ANSWER: B. A compiled language RATIONALE: A compiled language (e.g., C, C++, Java) is translated by a compiler into machine code before the program runs, producing a standalone executable that typically executes faster than interpreted code. Interpreted and scripting languages are translated line-by-line at runtime, and markup languages are for structuring documents.

  1. A junior developer is writing a Python script and assigns the integer value 10 to a variable, then later assigns the string "ten" to the same variable without causing an error. Which characteristic of the language allows this behavior? A. Static typing B. Dynamic typing C. Strong typing D. Explicit typing CORRECT ANSWER: B. Dynamic typing RATIONALE: In dynamically typed languages such as Python, JavaScript, and Ruby, variable types are checked at runtime and a variable's type may change based on the value assigned to it. Statically typed languages (e.g., C, C++, Java) require the type to be declared and fixed at compile time.
  2. A developer wants a compiler to report an error if an integer variable is assigned a string value. Which type of language

source code can run on Windows, Mac, or Linux as long as the interpreter is installed. Compiled, assembly, and machine languages are machine-specific.

  1. A developer is creating a web page and needs to describe the structure and formatting of the content using tags. Which type of language is the developer using? A. A compiled language B. A procedural language C. A markup language D. An object-oriented language CORRECT ANSWER: C. A markup language RATIONALE: Markup languages (e.g., HTML, XML) use tags to surround text and describe its structure, formatting, or meaning. They are not general-purpose programming languages. Compiled, procedural, and object-oriented languages are used for logic and computation.
  2. A programmer is using a language that organizes code around "objects" that contain both data (attributes) and operations (methods). The programmer creates classes like Person, Teacher, and Student to model real-world entities. Which characteristic describes this language? A. Dynamically typed B. Object-oriented C. Markup D. Statically typed

CORRECT ANSWER: B. Object-oriented RATIONALE: Object-oriented programming (OOP) organizes code around objects that encapsulate data and methods. Classes like Person, Teacher, and Student are typical OOP constructs. OOP supports encapsulation, inheritance, and polymorphism.

  1. A developer is reviewing a list of programming languages and needs to identify which one is NOT built on object- oriented design principles and instead follows a procedural paradigm. A. Java B. Python C. C++ D. C CORRECT ANSWER: D. C RATIONALE: C is a procedural programming language and does not natively support classes, objects, inheritance, or polymorphism. Java, Python, and C++ are object-oriented languages that provide built-in support for these concepts.
  2. A developer wants to use an existing library in their code to avoid rewriting tested functionality. What must the developer do first to make the library's functions and resources available? A. Write the library's functions from scratch B. Modify the library's functions

line-by-line at runtime, which adds overhead and typically results in slower execution.

  1. A programmer is writing a script to automate a repetitive task on a server. The script will be executed one statement at a time by a runtime environment. Which type of language is the programmer most likely using? A. A compiled language B. A scripting language C. An assembly language D. A markup language CORRECT ANSWER: B. A scripting language RATIONALE: Scripting languages (e.g., Python, JavaScript, Bash, Ruby) are typically interpreted at runtime and are widely used for automation, system administration, and web development. They execute statements sequentially through an interpreter rather than being compiled into machine code.
  2. A developer is working with a statically typed language and attempts to assign a string value to a variable that was declared as an integer. What is the most likely outcome at compile time? A. The program will run without error and convert the string to a number. B. The compiler will report a type mismatch error. C. The program will crash at runtime with a segmentation fault. D. The variable will automatically change its type to string.

CORRECT ANSWER: B. The compiler will report a type mismatch error. RATIONALE: In statically typed languages (e.g., C, C++, Java), variable types are checked at compile time. Assigning a string to an integer variable causes a compile-time type error, which prevents the program from being built and catches the mistake early.

  1. A developer is explaining the difference between high- level and low-level programming languages to a colleague. Which of the following best describes a high-level language? A. It is written in binary machine code. B. It is closely tied to the hardware and uses mnemonics. C. It is abstracted from the hardware and uses human-readable syntax. D. It can only run on one specific type of processor. CORRECT ANSWER: C. It is abstracted from the hardware and uses human-readable syntax. RATIONALE: High-level languages (e.g., Python, Java, C++) are abstracted from the hardware and use human-readable syntax, making them easier to learn and use. Low-level languages (e.g., assembly, machine code) are closely tied to the hardware and are much harder to read and write.
  2. A developer is deciding between using a compiled language and an interpreted language for a project that

JavaScript, Ruby) check variable types at runtime. A variable's type is determined by the value assigned to it, and type errors are only detected when the code is executed. Statically typed languages check types at compile time.

  1. A developer is writing a program that must interact directly with memory addresses and hardware registers. Which type of language is most appropriate for this low- level task? A. A high-level language like Python B. A low-level language like assembly C. A markup language like HTML D. A query language like SQL CORRECT ANSWER: B. A low-level language like assembly RATIONALE: Low-level languages such as assembly provide direct control over hardware and memory. High-level languages abstract away these details, markup languages are for document structure, and query languages are for database interaction.
  2. A developer is using a language that supports multiple programming paradigms, including procedural, object- oriented, and functional programming. Which term best describes such a language? A. A single-paradigm language B. A multi-paradigm language

C. A markup language D. An assembly language CORRECT ANSWER: B. A multi-paradigm language RATIONALE: A multi-paradigm language (e.g., Python, C++, JavaScript) supports more than one programming paradigm. This gives developers flexibility to choose the most appropriate approach for a given problem. Single-paradigm languages are restricted to one style.

  1. A developer is writing a script in a language where variables do not need to be declared with an explicit type before use. The type is inferred based on the assigned value. Which characteristic of the language does this describe? A. Static typing B. Dynamic typing C. Strong typing D. Explicit typing CORRECT ANSWER: B. Dynamic typing RATIONALE: In dynamically typed languages, variable types are inferred at runtime based on the assigned value, and explicit type declarations are not required. Static typing requires explicit type declarations and checks types at compile time.
  2. A developer is explaining the concept of a programming library to a junior team member. Which of the following best describes a library?

bytecode can run on any device that has a JVM installed, without recompilation.

  1. A developer is comparing the error-detection capabilities of statically typed and dynamically typed languages. Which statement best describes a key advantage of statically typed languages? A. They detect type errors at compile time, before the program runs. B. They allow variables to change type during execution. C. They do not require any type checking. D. They execute faster than dynamically typed languages in all cases. CORRECT ANSWER: A. They detect type errors at compile time, before the program runs. RATIONALE: A key advantage of statically typed languages is that type errors are detected at compile time, allowing developers to catch and fix mistakes before the program is executed. This improves code reliability and reduces runtime failures.
  2. A developer is writing a program in a language that requires the programmer to specify the type of every variable explicitly (e.g., int age = 30;). Which characteristic does this describe? A. Dynamic typing B. Static typing

C. Implicit typing D. Weak typing CORRECT ANSWER: B. Static typing RATIONALE: Static typing requires the programmer to declare the type of each variable explicitly, and the type is fixed at compile time. Dynamic typing allows variables to change type at runtime, and implicit typing infers types without explicit declarations.

  1. A developer is choosing a language for a project that involves complex mathematical computations and requires high performance. Which type of language is generally preferred for performance-critical applications? A. A compiled language B. An interpreted language C. A markup language D. A query language CORRECT ANSWER: A. A compiled language RATIONALE: Compiled languages (e.g., C, C++) are generally preferred for performance-critical applications because they are translated directly into machine code, which executes faster than interpreted code. Interpreted languages add runtime overhead, and markup and query languages are not designed for general computation.
  2. A developer is explaining that a certain language is "platform-independent" because it runs on an interpreter

functions is that the code has already been tested and validated by the library developers. This saves time, reduces the likelihood of bugs, and improves reliability, since the code is proven and vetted.

  1. A developer is describing a programming paradigm that focuses on "what to solve" rather than "how to solve it," using declarative statements. Which paradigm does this describe? A. Procedural programming B. Object-oriented programming C. Declarative programming D. Imperative programming CORRECT ANSWER: C. Declarative programming RATIONALE: Declarative programming focuses on describing what the program should accomplish rather than specifying how to accomplish it step by step. Imperative and procedural programming focus on how to solve a problem through explicit sequences of commands. Object-oriented programming organizes code around objects.
  2. A developer is writing a program and needs to store a value that can be changed during program execution. Which programming concept is used for this purpose? A. A constant B. A variable

C. A function D. A class CORRECT ANSWER: B. A variable RATIONALE: A variable is a symbolic name for a storage location in memory whose value can be changed during program execution. A constant holds a value that cannot be changed after it is set, and functions and classes are different programming constructs.

  1. A developer is writing a script to calculate the total cost of items in a shopping cart. Which data type is most appropriate for storing the price of a single item, which may include cents (e.g., $19.99)? A. Boolean B. String C. Float D. Integer CORRECT ANSWER: C. Float RATIONALE: Prices are typically represented as decimal numbers to include fractional values (cents). A float (or double) is the appropriate data type for storing such fractional values. Integers cannot represent cents, booleans represent true/false, and strings are for text.
  2. A developer is writing a program that counts the number of planes in a hangar. The count must be a whole number. Which data type should be used for this value?

A. age > 18 && age < 24 B. age >= 18 && age <= 24 C. age >= 18 || age <= 24 D. age == 18 || age == 24 CORRECT ANSWER: B. age >= 18 && age <= 24 RATIONALE: To check if a value is within an inclusive range, the logical AND operator (&&) is used with two comparisons: age >= 18 and age <= 24. Option A excludes the boundary values, Option C uses OR (which would be true for nearly all ages), and Option D only checks the boundary values themselves.

  1. A developer is declaring a constant for the number of seconds in a minute, which is 60. The value should not change during program execution. Which keyword or construct is most appropriate for this declaration in most languages? A. A variable declared with var B. A constant declared with const or final C. A function D. A class CORRECT ANSWER: B. A constant declared with const or final RATIONALE: A constant (e.g., using const in JavaScript/C++, final in Java) is used to store a value that should not change during program execution. Variables (var, let) allow reassignment, and functions and classes are different constructs.
  1. A developer is writing a program that needs to convert a user's input (which is initially a string) into a number for calculation. Which concept does this describe? A. Type conversion (casting) B. Variable declaration C. Function definition D. Loop iteration CORRECT ANSWER: A. Type conversion (casting) RATIONALE: Type conversion, or casting, is the process of converting a value from one data type to another (e.g., converting a string to an integer or float). Variable declaration creates a variable, function definition creates a function, and loop iteration repeats code.
  2. A developer is evaluating the following expression: 5 + 3 * 2. According to standard operator precedence, what is the result? A. 16 B. 13 C. 11 D. 10 CORRECT ANSWER: C. 11 RATIONALE: Multiplication (*) has higher precedence than addition (+). Therefore, the expression is evaluated as 5 + (3 * 2) = 5 + 6 = 11. Failing to follow precedence would incorrectly produce 16.