Unit 3 of 5
Study guide for DSST DSST Computing and Information Technology — Unit 3: Programming Concepts. Practice questions, key concepts, and exam tips.
42
Practice Questions
16
Flashcards
6
Key Topics
Try these 5 questions from this unit. Sign up for full access to all 42.
A student is writing a program to track student grades across multiple functions. She declares a variable `totalGrades` as an integer inside her `calculateAverage()` function. Later, she tries to access this variable from a different function called `displayResults()` to print the final average. The program compiles but crashes at runtime when `displayResults()` tries to use `totalGrades`. Which concept best explains why this error occurs?
Answer: A — The correct answer is A. This question tests understanding of variable scope, a fundamental programming concept. The variable `totalGrades` is declared locally within `calculateAverage()`, meaning it only exists during that function's execution. Once the function returns, the variable is destroyed, and `displayResults()` cannot access it. This is proper scope encapsulation. Option B is incorrect because data type mismatch typically causes compilation errors, not runtime crashes, and integers can be passed between functions. Option C is a misconception that scope problems relate to memory allocation rather than visibility rules. Option D is false because modern languages allow identical variable names in different scopes without collision—the compiler distinguishes them by scope. This question requires students to apply their understanding of scope rules to diagnose a real programming problem.
A company is developing a new e-commerce website and wants to implement a programming approach that focuses on objects and their interactions. The development team is looking for a paradigm that will allow them to model real-world entities and simulate their behavior. Which programming paradigm is most suitable for this project?
Answer: A — Object-Oriented Programming (OOP) is the most suitable paradigm for this project because it focuses on objects and their interactions, allowing developers to model real-world entities and simulate their behavior. OOP provides features such as encapsulation, inheritance, and polymorphism, which are essential for complex systems like e-commerce websites. The other options are incorrect because Functional Programming (B) focuses on functions and their composition, Imperative Programming (C) focuses on steps and procedures, and Declarative Programming (D) focuses on what the program should accomplish, rather than how it should accomplish it.
A company is developing a new web application that requires a high degree of modularity and reusability. The development team is considering two programming paradigms: object-oriented programming (OOP) and functional programming (FP). Which paradigm is more suitable for this project?
Answer: A — Object-oriented programming (OOP) is more suitable for this project because it emphasizes modularity, reusability, and encapsulation, which are essential for complex web applications. OOP allows developers to create self-contained modules (classes) that can be easily reused and combined to form larger systems. In contrast, functional programming (FP) is more focused on pure functions, immutability, and recursion, which may not provide the same level of modularity and reusability as OOP. Imperative programming is a paradigm that focuses on steps and actions, while declarative programming focuses on what the program should accomplish, but neither is as well-suited for this project as OOP.
A software development company is tasked with creating a web application that allows users to interact with a database. The application requires a high degree of flexibility and customization. Which programming paradigm is most suitable for this task?
Answer: B — Object-oriented programming is the most suitable paradigm for this task because it allows for the creation of reusable and modular code, which is ideal for complex and customizable applications. Procedural programming (A) is not suitable because it focuses on procedures and steps, rather than objects and interactions. Functional programming (C) is not suitable because it focuses on functions and immutability, rather than objects and state changes. Declarative programming (D) is not suitable because it focuses on what the program should accomplish, rather than how it should accomplish it.
A student is writing a program to track student grades. She needs to store a student's name, their GPA (like 3.85), and the number of courses they've completed. Which combination of data types would be most appropriate for storing these three pieces of information?
Answer: C — The correct answer is C (string, float, integer) because: a student's name is text (string), GPA is a decimal number requiring precision (float), and the number of courses is a whole number (integer). Option A incorrectly treats GPA as text, losing mathematical functionality. Option B fails to recognize that names aren't numeric and that GPA requires decimal precision. Option D confuses the data types by treating the number of courses as a float (unnecessary) and GPA as an integer (losing decimal precision like 0.85). This question tests the student's ability to match real-world data to appropriate programming data types.
DSST® is a trademark owned by Prometric, which is not affiliated with, and does not endorse, this product.