CCNA Software Dev Concepts Questions

75 of 80 questions · Page 1/2 · Software Dev Concepts topic · Answers revealed

1
MCQmedium

A web application is not responding to user input. The developer checks the code and finds an infinite loop. Which change will fix the infinite loop?

A.Remove the loop body
B.Add a break statement
C.Add a counter variable that increments and check it in the condition
D.Change from a for loop to a while loop
AnswerC

A counter limits the number of iterations, ensuring the loop eventually ends.

Why this answer

Option C is correct because an infinite loop occurs when the loop's termination condition is never met. By adding a counter variable that increments with each iteration and checking it in the condition, the loop will eventually exit when the counter reaches a specified limit, thus breaking the infinite loop.

Exam trap

The trap here is that candidates may think changing the loop type (e.g., for to while) or removing the body will fix the infinite loop, but the core issue is the lack of a proper termination condition, which only a counter or similar mechanism can resolve.

How to eliminate wrong answers

Option A is wrong because removing the loop body does not change the loop's condition; the loop will still run infinitely if the condition never becomes false. Option B is wrong because adding a break statement will exit the loop immediately, but it does not address the root cause of the infinite loop and may lead to premature termination or logic errors. Option D is wrong because changing from a for loop to a while loop does not inherently fix an infinite loop; the condition must still be properly defined to allow termination.

2
MCQeasy

A small e-commerce company uses a monolithic web application hosted on a single server. During peak shopping hours, the server becomes overloaded, causing slow page loads and occasional timeouts. The development team wants to improve scalability and maintainability. They are considering breaking the application into smaller, independent services that can be developed, deployed, and scaled separately. Which approach should the team adopt?

A.Migrate to a microservices architecture.
B.Move the application to a serverless computing platform.
C.Implement a service-oriented architecture (SOA) with an enterprise service bus.
D.Containerize the existing monolithic application.
AnswerA

Microservices break the app into small, independent services for better scalability and maintainability.

Why this answer

Microservices architecture involves decomposing an application into small, independent services. Option A is correct. Option B is incorrect because a service-oriented architecture (SOA) is similar but often uses an enterprise service bus, which may be less granular.

Option C is incorrect because containerization is a deployment method, not an architecture pattern. Option D is incorrect because serverless is a compute model, not an architecture pattern for breaking up a monolith.

3
Multi-Selectmedium

Which TWO of the following are common characteristics of compiled programming languages?

Select 2 answers
A.The code is executed line-by-line by an interpreter.
B.The resulting executable is platform-specific.
C.Variables do not need to be declared before use.
D.The source code is translated into machine code before execution.
E.The source code is compiled every time the program runs.
AnswersB, D

Machine code is tied to a specific CPU architecture and OS.

Why this answer

Option B is correct because compiled languages produce machine code that is specific to the target operating system and processor architecture. This platform-specific executable cannot run on a different OS or CPU without recompilation, which is a defining characteristic of compiled languages like C or C++.

Exam trap

The trap here is that candidates often confuse 'compiled every time the program runs' (Option E) with the actual compilation process, mistakenly thinking recompilation occurs at each execution, when in fact the executable is pre-built and reused.

4
MCQhard

Based on the exhibit, what actions are permitted by this policy?

A.GetObject and ListObjects
B.GetObject only
C.GetObject and DeleteObject
D.PutObject and GetObject
AnswerB

The Allow statement permits GetObject; DeleteObject is denied.

Why this answer

The policy has an Allow statement for s3:GetObject (read) and a Deny statement for s3:DeleteObject. Deny overrides Allow. No other actions are mentioned, so only GetObject is allowed.

ListObjects is not explicitly allowed. PutObject is not mentioned.

5
MCQhard

During a code review, a team notices that a function modifies a global variable instead of returning a value. Which software development principle is being violated?

A.Encapsulation
B.Polymorphism
C.Modularity
D.Inheritance
AnswerC

Modularity emphasizes that functions should be independent and avoid global side effects.

Why this answer

Option C is correct because functions should ideally be self-contained and not rely on external state (modularity). Option A (encapsulation) is about hiding data; Option B (polymorphism) is about behaving differently based on type; Option D (inheritance) is about class hierarchies.

6
MCQhard

A software developer is using an integrated development environment (IDE) to write a Python script that processes a CSV file containing customer data. The script uses a for loop to iterate over rows and calculates a total purchase amount. When the developer runs the script, it throws an error: "IndexError: list index out of range". The developer suspects the error occurs when the script tries to access a column that doesn't exist in some rows. Which debugging strategy should the developer use first to isolate the issue?

A.Rewrite the script to use a dictionary instead of a list.
B.Add a try-except block to catch the exception and continue processing.
C.Examine the CSV file to ensure all rows have the same number of columns.
D.Place a breakpoint inside the loop and step through each row in debug mode.
AnswerD

Debugging allows step-by-step execution to identify which row and column access causes the IndexError.

Why this answer

Using a debugger to step through the loop allows inspection of each row and identification of which row causes the error. Adding a try-except block masks the problem. Checking the file beforehand might not reveal the exact runtime issue.

Rewriting the script changes the approach without addressing the root cause.

7
MCQhard

A web application needs to send user registration data to a server. Which HTTP method should be used?

A.PUT
B.DELETE
C.POST
D.GET
AnswerC

POST sends data to create a new resource, suitable for registration.

Why this answer

The correct answer is A: POST. POST is used to send data to the server to create a resource. GET (B) retrieves data.

PUT (C) updates a resource, but is idempotent and typically used for full updates. DELETE (D) removes data.

8
MCQhard

A developer is testing a piece of code that calculates discounts. The code should give 10% off for orders over $100, and 5% off for orders between $50 and $100. Which test input set would best verify boundary conditions?

A.$50, $100, $150
B.$0, $50, $100, $200
C.$50.00, $100.00
D.$49.99, $50.00, $99.99, $100.00, $100.01
AnswerD

This set tests below, at, and above each boundary, ensuring edge cases are covered.

Why this answer

Boundary testing requires values at, just below, and just above each boundary. Option A covers all boundaries ($49.99, $50.00, $99.99, $100.00, $100.01). Others miss some boundaries or are not precise.

9
MCQeasy

A developer writes a script to calculate the average of a list of numbers. The script uses a loop to sum the numbers and then divides by the count. Which programming concept does this represent?

A.Iteration
B.Selection
C.Recursion
D.Sequence
AnswerA

Iteration uses loops to repeat actions, as in summing numbers.

Why this answer

Option B is correct because the script uses a loop to iterate through the list, which is a core iteration concept. Option A (selection) involves conditional statements; Option C (sequence) is just linear execution; Option D (recursion) involves a function calling itself.

10
MCQmedium

Based on the exhibit, which commit introduced the password validation fix?

A.e3a1b2c
B.l0m1n2o
C.d4f5e6g
D.h7i8j9k
AnswerC

This commit has the message 'Fix password validation bug'.

Why this answer

The git log shows commits with short hashes and messages. The second commit (d4f5e6g) mentions 'Fix password validation bug'. The first commit is e3a1b2c (login feature), third is h7i8j9k (registration), fourth is initial commit.

11
MCQeasy

A programmer needs to store a customer's name in a variable. Which data type is most appropriate?

A.String
B.Float
C.Integer
D.Boolean
AnswerA

String stores text such as names.

Why this answer

Option D is correct because a name is a string of characters. Option A (integer) is for whole numbers; Option B (float) for decimals; Option C (boolean) for true/false.

12
MCQhard

What is the output of the pseudocode in the exhibit?

A.4
B.6
C.5
D.1
AnswerC

num starts at 1, increments to 5, then exits and prints 5.

Why this answer

The loop increments num from 1 until num is no longer less than 5, so it stops when num is 5, which is printed.

13
MCQhard

A developer is troubleshooting an issue where a user can list the objects in an S3 bucket but cannot download any of them. Based on the exhibit, what is the most likely cause?

A.The user lacks permissions to list the bucket.
B.The Allow statement on s3:ListBucket also allows downloads.
C.The Deny statement on s3:GetObject explicitly denies object retrieval.
D.The policy is malformed and causes an error.
AnswerC

Deny overrides Allow, preventing downloads.

Why this answer

The exhibit shows an explicit Deny statement for s3:GetObject, which overrides any Allow statements due to AWS IAM policy evaluation logic. Even if the user has s3:ListBucket permission to list objects, the Deny on s3:GetObject prevents downloading any objects. This is the most likely cause because AWS Deny statements are absolute and cannot be overridden by Allow statements.

Exam trap

The trap here is that candidates often assume that having ListBucket permission implies full read access, but AWS separates listing (s3:ListBucket) from reading object data (s3:GetObject), and an explicit Deny on GetObject overrides any Allow.

How to eliminate wrong answers

Option A is wrong because the user can list objects, which requires s3:ListBucket permission, so they clearly have that permission. Option B is wrong because s3:ListBucket only grants permission to list objects, not to download them; downloading requires s3:GetObject, which is a separate action. Option D is wrong because if the policy were malformed, AWS would return a policy validation error and the bucket operations would likely fail entirely, but the user can still list objects, indicating the policy is syntactically valid.

14
Multi-Selecthard

Which THREE of the following are phases in the software development lifecycle (SDLC)?

Select 3 answers
A.Design
B.Testing
C.Deployment
D.Requirements gathering
E.Compilation
AnswersA, B, D

Design phase involves creating the software architecture and plan.

Why this answer

Requirements gathering, design, and testing are standard SDLC phases. Compilation is a technical step, not a phase. Deployment is also a phase, but only three are correct? Actually deployment is a phase, but our options: Requirements, Design, Compilation, Testing, Deployment.

So three are Requirements, Design, Testing. Compilation is not a phase, and Deployment is also a phase but we need exactly three; typical core phases are Requirements, Design, Implementation, Testing, Deployment, Maintenance. So we choose Requirements, Design, Testing.

Implementation would also be valid but not in options. So three correct: A, B, D.

15
MCQmedium

A programmer is writing an if-else statement to check if a user is an admin. The code should set a variable 'accessLevel' to 'full' if admin, else 'restricted'. Which code snippet accomplishes this?

A.if (isAdmin == true) { accessLevel = 'full'; } else { accessLevel = 'restricted'; }
B.if (isAdmin == false) { accessLevel = 'full'; } else { accessLevel = 'restricted'; }
C.if (isAdmin = true) { accessLevel = 'full'; } else { accessLevel = 'restricted'; }
D.if (isAdmin == true) { accessLevel = 'restricted'; } else { accessLevel = 'full'; }
AnswerA

Correctly assigns full if admin, restricted otherwise.

Why this answer

Option D is correct because it assigns 'full' to accessLevel when isAdmin is true, otherwise 'restricted'. Option A has syntax error (assignment in condition); Option B uses == which is comparison but assigns in both cases incorrectly; Option C assigns 'full' only when false.

16
Multi-Selecteasy

Which TWO of the following are valid data types in most programming languages?

Select 2 answers
A.Boolean
B.Character
C.Array
D.Integer
E.Bit
AnswersA, D

Boolean represents true/false values.

Why this answer

Options A and D are correct: integer and boolean are standard data types. Option B is not a standard type (bit is sometimes but boolean covers it); Option C is a structure, not a primitive type; Option E (character) is also valid but we only need two, and boolean and integer are more fundamental. Actually character is also valid, but to match exactly two, we choose integer and boolean.

17
MCQmedium

A program needs to display a message based on a user's age. If age is 18 or over, it displays 'Adult'; otherwise, it displays 'Minor'. Which control structure should be used?

A.If-else statement
B.For loop
C.Switch-case statement
D.While loop
AnswerA

If-else evaluates a condition and executes one of two blocks.

Why this answer

An if-else statement is used to choose between two code paths based on a condition. A for loop is for iteration. A while loop repeats until a condition is false.

A switch-case tests multiple discrete values.

18
MCQmedium

A developer is debugging a script that calculates the average of a list of numbers. The output is always incorrect. Which type of error is most likely the cause?

A.Runtime error
B.Logic error
C.Syntax error
D.Compile error
AnswerB

Logic errors occur when the code runs but produces incorrect results due to flawed reasoning.

Why this answer

The correct answer is B: Logic error. The script runs without syntax or runtime errors but produces wrong results, indicating a flaw in the algorithm or logic. Option A (syntax error) would prevent execution.

Option C (runtime error) would cause a crash. Option D (compile error) is not applicable to interpreted scripts.

19
MCQmedium

Which coding best practice improves code readability and maintainability?

A.Using global variables for all data
B.Using meaningful variable names
C.Hard-coding values whenever possible
D.Writing long, single functions
AnswerB

Meaningful names clarify the purpose of variables, improving readability and maintainability.

Why this answer

Using meaningful variable names makes code self-documenting. Global variables reduce readability. Long functions are harder to understand.

Hard-coded values reduce flexibility.

20
MCQeasy

A developer needs to store a list of employee names. Which data structure is most appropriate?

A.String
B.Array
C.Boolean
D.Integer
AnswerB

An array can hold multiple values of the same type, like a list of names.

Why this answer

An array is the most appropriate data structure for storing a list of employee names because it allows multiple values (strings) to be stored in a single, ordered collection. Unlike a single string, which holds only one value, an array can hold many strings and provides indexed access to each element, making it ideal for lists of items.

Exam trap

The trap here is that candidates may confuse a single string with a collection, thinking a string can hold multiple names by concatenation, but the question specifically asks for a 'list' structure, which requires an array or similar collection type.

How to eliminate wrong answers

Option A is wrong because a string is a single sequence of characters, not a collection; storing multiple names would require concatenation or a single long string, which is inefficient and loses individual name access. Option C is wrong because a Boolean can only represent true or false, not a list of names. Option D is wrong because an integer stores only numeric values, not text-based employee names.

21
MCQeasy

A developer is creating a program that must respond to user actions such as button clicks and mouse movements. Which programming paradigm is most suitable?

A.Event-driven programming
B.Object-oriented programming
C.Functional programming
D.Procedural programming
AnswerA

Event-driven programming is designed to respond to user actions and system events, making it ideal for GUI applications.

Why this answer

Event-driven programming is best for GUI applications because it waits for and handles events (user actions). Procedural programming does not handle events naturally. Functional programming focuses on functions, not events.

Object-oriented programming can encapsulate events but the event-driven paradigm is the most direct.

22
Multi-Selecteasy

A developer is designing a website and needs to choose a client-side scripting language. Which of the following are scripting languages? (Choose two.)

Select 2 answers
A.JavaScript
B.Java
C.HTML
D.C++
E.Python
AnswersA, E

JavaScript is a client-side scripting language used in web development.

Why this answer

JavaScript and Python are scripting languages. Java and C++ are compiled languages; HTML is a markup language.

23
MCQeasy

Which of the following correctly declares a variable to store a person's age in Python?

A.var age = 25
B.int age = 25
C.age == 25
D.age = 25
AnswerD

This correctly assigns the value 25 to the variable age.

Why this answer

In Python, variables are dynamically typed. 'age = 25' assigns an integer to the variable. 'int age = 25' is C-like syntax. 'age == 25' is a comparison. 'var age = 25' is not Python syntax.

24
Multi-Selectmedium

A software development team is adopting an Agile methodology. Which of the following are characteristics of Agile? (Choose three.)

Select 3 answers
A.Strict adherence to a fixed plan
B.Customer collaboration
C.Responding to change over following a plan
D.Emphasis on documentation over working software
E.Iterative development
AnswersB, C, E

Customer collaboration is a core Agile principle.

Why this answer

Agile emphasizes iterative development, customer collaboration, and responding to change. Strict plans and heavy documentation are more characteristic of waterfall.

25
MCQhard

Refer to the exhibit. A cloud engineer is reviewing a JSON configuration for an auto-scaling group. Currently, there are 3 instances and the CPU usage is 85%. What will happen next?

A.No action will be taken.
B.An instance will be removed.
C.The configuration will be flagged as invalid.
D.An instance will be added.
AnswerD

CPU > 80% triggers scale-up by 1 instance.

Why this answer

Option D is correct because the auto-scaling group's configuration specifies a scale-out policy triggered when the average CPU utilization exceeds 80% for a sustained period. With CPU usage at 85% and only 3 instances running, the condition is met, so the auto-scaling group will launch an additional instance to distribute the load and reduce CPU usage.

Exam trap

The trap here is that candidates may think no action is taken because they overlook the threshold value or assume the current CPU usage must be sustained for a longer period, but the question implies the condition is met based on the given 85% value.

How to eliminate wrong answers

Option A is wrong because the CPU usage of 85% exceeds the specified threshold of 80%, so the auto-scaling policy will take action rather than remain idle. Option B is wrong because a scale-in (removing an instance) occurs when CPU usage falls below a lower threshold, not when it is high; removing an instance would worsen the overload. Option C is wrong because the configuration is valid JSON and the threshold values are correctly defined; there is no syntax or logic error that would flag it as invalid.

26
Multi-Selecthard

Which TWO of the following are characteristics of object-oriented programming (OOP)?

Select 2 answers
A.Top-down design
B.Use of global functions
C.Inheritance
D.Encapsulation
E.Recursion
AnswersC, D

Inheritance is a core OOP concept.

Why this answer

Options A and C are correct: inheritance allows classes to derive from others, and encapsulation hides internal state. Option B is wrong because recursion is not OOP-specific; Option D (global functions) is procedural; Option E (top-down design) is structured programming.

27
Multi-Selectmedium

Which THREE of the following are common phases in the software development life cycle (SDLC)?

Select 3 answers
A.Requirements gathering
B.Release
C.Coding
D.Design
E.Testing
AnswersA, D, E

Requirements gathering is a key phase in SDLC.

Why this answer

Options A, C, and E are correct: requirements gathering, design, and testing are standard SDLC phases. Option B is not a phase (coding is part of implementation); Option D is not a typical phase (maintenance is phase but 'release' is often part of deployment). Actually maintenance is a phase, but release is a step within deployment.

For ITF, common phases include planning, analysis, design, implementation, testing, deployment, maintenance. Here, 'coding' is not a phase name; 'release' is not a phase. So A, C, E fit.

28
MCQmedium

A programmer writes a script that automates the backup of files every night. Which type of programming paradigm is this script likely using?

A.Event-driven programming
B.Procedural programming
C.Object-oriented programming
D.Functional programming
AnswerB

Procedural programming is based on a sequence of instructions, suitable for automation tasks.

Why this answer

A simple backup script is typically a linear sequence of steps, characteristic of procedural programming. Object-oriented would involve classes and objects; event-driven waits for events; functional uses pure functions and immutability.

29
MCQhard

A project has frequent requirement changes and the team needs to deliver working software in short cycles. Which software development methodology is most appropriate?

A.Waterfall
B.Agile
C.DevOps
D.Spiral
AnswerB

Agile embraces change and delivers working software in short iterations, making it ideal for projects with frequent requirement changes.

Why this answer

Agile methodology emphasizes iterative development, frequent delivery, and adapting to change. Waterfall is rigid and sequential. Spiral focuses on risk, but Agile is best for changing requirements.

DevOps is more about deployment and operations.

30
MCQeasy

Which tool is commonly used for automated testing in software development?

A.Jenkins
B.Git
C.Visual Studio
D.Docker
AnswerA

Jenkins automates testing and build processes.

Why this answer

The correct answer is D: Jenkins. Jenkins is a continuous integration tool that automates testing. Docker (A) is for containerization.

Git (B) is for version control. Visual Studio (C) is an IDE, but not specifically for automated testing.

31
Multi-Selectmedium

Which TWO of the following are characteristics of object-oriented programming (OOP)?

Select 2 answers
A.Polymorphism
B.Inheritance
C.Top-down design
D.Encapsulation
E.Use of functions and procedures
AnswersB, D

Inheritance allows a class to derive from another class.

Why this answer

Encapsulation and inheritance are core OOP concepts. Procedural programming uses functions, not objects. Top-down design is associated with procedural programming.

Polymorphism is also an OOP concept, but the question asks for two; we have encapsulation and inheritance.

32
MCQeasy

Which of the following best describes the difference between a compiler and an interpreter?

A.Compiled programs run slower than interpreted programs.
B.A compiler executes code line by line; an interpreter translates the entire program at once.
C.A compiler translates the entire source code into machine code before execution; an interpreter executes code line by line.
D.A compiler checks for syntax errors at runtime; an interpreter checks at compile time.
AnswerC

This correctly describes the difference.

Why this answer

A compiler translates source code into machine code all at once, producing an executable. An interpreter executes code line by line. Both check syntax but at different times.

Compilers usually generate faster programs.

33
MCQeasy

A small business uses a single Linux server to host a custom inventory management application written in Python. The application reads from a CSV file on the server to display current stock levels. Recently, users have reported that the inventory numbers are incorrect and sometimes the application crashes with a 'Permission denied' error when trying to save updates. The server has two user accounts: 'admin' (with sudo privileges) and 'app_user' (a standard user under which the application runs). The CSV file is located at /var/data/inventory.csv and currently has permissions -rw-rw---- and owner root:root. The application code uses the open() function to read and write the file. Which of the following actions should be taken to resolve the issue?

A.Modify the application to run as 'admin' using sudo.
B.Set the file permissions to 644 so all users can read the file.
C.Change the file owner to 'app_user' and set permissions to 755.
D.Change the group ownership to a group that includes 'app_user' and ensure the file has group write permission.
AnswerD

This grants the application write access while maintaining security.

Why this answer

The application runs as 'app_user', which needs to write to /var/data/inventory.csv. The file is owned by root:root with permissions -rw-rw----, meaning only root and the root group can write. Changing the group ownership to a group that includes 'app_user' and granting group write permission (e.g., chown root:app_group /var/data/inventory.csv; chmod 664 /var/data/inventory.csv) allows the application to write without elevating privileges or exposing the file to all users.

Exam trap

The trap here is that candidates often assume changing file permissions to 644 (read for all) or changing the owner to the application user is sufficient, overlooking that the application needs write access and that group-based permissions provide a secure, least-privilege solution.

How to eliminate wrong answers

Option A is wrong because running the application as 'admin' with sudo would grant unnecessary root privileges, violating the principle of least privilege and introducing security risks. Option B is wrong because setting permissions to 644 would allow all users to read the file, but the application also needs to write; 644 does not include write permission for the group or others, so the 'Permission denied' error would persist on write attempts. Option C is wrong because changing the owner to 'app_user' with permissions 755 gives the owner write permission, but 755 grants read and execute to group and others, which is overly permissive and still does not address the group write requirement; additionally, changing owner to a non-root user may break other system processes that expect root ownership.

34
MCQhard

Consider the following algorithm: SET x = 5 SET y = 2 SET result = x ^ y OUTPUT result Assuming '^' is the exponentiation operator, what is the output?

A.32
B.7
C.10
D.25
AnswerD

5^2 = 25.

Why this answer

5 raised to the power of 2 equals 25. The caret (^) is commonly used for exponentiation in some languages. Multiplication would be 10, addition 7, bitwise XOR would be 7 (5 XOR 2 = 7) but here it's exponentiation.

35
MCQeasy

A junior developer needs to create a simple program that adds two numbers and displays the result. Which programming paradigm is most suitable for this task?

A.Functional programming
B.Declarative programming
C.Object-oriented programming
D.Procedural programming
AnswerD

Procedural programming uses a linear sequence of instructions, ideal for simple calculations.

Why this answer

The correct answer is A: Procedural programming. A simple sequential task like adding numbers is well-suited to procedural programming. OOP (B) adds unnecessary complexity.

Functional (C) and declarative (D) are not typical for such straightforward tasks.

36
Multi-Selectmedium

Which TWO of the following are common characteristics of object-oriented programming languages?

Select 2 answers
A.Procedural programming
B.Polymorphism
C.Functional programming
D.Inheritance
E.Encapsulation
AnswersD, E

Inheritance allows a class to derive properties from another class.

Why this answer

Inheritance is a core characteristic of object-oriented programming (OOP) that allows a class to derive properties and behaviors from a parent class, promoting code reuse and hierarchical relationships. This is a defining feature of OOP languages like Java, C++, and Python, distinguishing them from procedural or functional paradigms.

Exam trap

The trap here is that candidates may confuse 'characteristics of OOP' with 'programming paradigms' and incorrectly select procedural or functional programming, which are separate paradigms, not OOP features.

37
MCQhard

A software application is experiencing performance degradation. The team suspects a memory leak. Which development practice should be used to identify the source of the leak?

A.Unit testing
B.Debugging
C.Profiling
D.Code review
AnswerC

Profiling tools track resource usage, including memory allocation, to identify leaks.

Why this answer

Profiling is the correct practice because it involves monitoring the application's runtime behavior, including memory allocation and garbage collection. A memory profiler can track object creation and retention, pinpointing which objects are not being released and causing the leak. This is the standard approach for diagnosing memory leaks in languages like Java or C#.

Exam trap

The trap here is that candidates confuse debugging (step-by-step logic inspection) with profiling (runtime performance and memory analysis), assuming any performance issue can be solved by stepping through code, but memory leaks require heap analysis tools.

How to eliminate wrong answers

Option A is wrong because unit testing validates individual code units for correctness, not runtime memory usage patterns; it cannot detect a memory leak that manifests over time. Option B is wrong because debugging is used to step through code logic and inspect variables at a specific point, but it does not provide continuous memory allocation statistics or identify unreleased objects. Option D is wrong because code review involves manually examining source code for logical errors or style issues, but it cannot reveal runtime memory behavior such as objects that are inadvertently held in memory.

38
MCQmedium

A developer is troubleshooting a program that produces unexpected results. The code includes a loop that repeats 10 times but the output shows only 9 values. Which debugging step should be taken first?

A.Add a print statement inside the loop
B.Check the loop condition and initial value
C.Reinstall the programming environment
D.Comment out all lines except the loop
AnswerB

A wrong condition or initialization can cause off-by-one errors.

Why this answer

Option B is correct because checking the loop's condition is the most direct way to verify the iteration count. Option A (commenting out code) may hide the issue; Option C (adding print statements) is useful but condition check is more fundamental; Option D (reinstalling) is overkill.

39
MCQhard

Two developers have edited the same file and created different versions. To integrate their changes, which Git operation should they perform?

A.git pull
B.git merge
C.git rebase
D.git commit
AnswerB

git merge combines branches, integrating changes.

Why this answer

The correct answer is A: git merge. Merging combines different branches. git rebase (B) rewrites commit history. git pull (C) fetches and merges, but the question specifically asks for the operation to integrate changes. git commit (D) saves local changes.

40
MCQmedium

A company's IT department is developing a new internal tool to track employee leave requests. The development team is using a waterfall model. After the requirements phase, they create a detailed design document. During implementation, a key stakeholder requests a new feature that requires a change to the database schema. The team is reluctant to accommodate the change because they have already started coding. Which approach should the team take to best handle this situation while adhering to the waterfall model?

A.Switch to an agile methodology to handle the change.
B.Immediately stop coding and incorporate the change into the design document.
C.Complete the current phase, then formally review and update the design document before moving to testing.
D.Ignore the request because it wasn't in the original requirements.
AnswerC

This follows waterfall's phase-gate approach, allowing changes between phases.

Why this answer

In waterfall, changes are typically handled at phase boundaries. Completing the current implementation phase, then formally updating the design before testing allows structured change control. Ignoring the request or stopping immediately disrupts the process.

Switching to agile mid-project is not practical.

41
MCQeasy

Based on the exhibit, what will be the last value output?

A.6
B.5
C.10
D.1
AnswerB

5 is output when count=5, then count becomes 6 and loop terminates.

Why this answer

The loop runs while count <= 5. It outputs 1,2,3,4,5. The last output is 5.

Then count becomes 6 and loop exits. 1 is first, 6 is not output because loop ends.

42
MCQmedium

Given the following pseudocode that calculates the average of a list of numbers, which error will occur? SET total = 0 SET count = 0 FOR EACH number IN list total = total + number count = count + 1 ENDFOR SET average = total / count OUTPUT average

A.Compile-time error
B.Logic error
C.Syntax error
D.Runtime error
AnswerD

If the list is empty, division by zero causes a runtime error.

Why this answer

If the list is empty, count remains 0, and division by zero occurs. No syntax error exists. A logic error would produce wrong results but division by zero is a runtime error.

Compile-time errors are not relevant to pseudocode.

43
MCQmedium

A team of developers is collaborating on a mobile app using Git. One developer, Alice, is working on a new feature in a branch called "new-feature". Bob, another developer, has pushed several bug fixes to the main branch. Alice now wants to incorporate Bob's bug fixes into her feature branch. Which sequence of Git commands should Alice use to achieve this with minimal disruption?

A.git fetch, git rebase new-feature onto origin/main, then force push.
B.git checkout new-feature, git merge main, then resolve conflicts if any.
C.git checkout -b new-feature, git push.
D.git checkout main, git pull, git merge new-feature, then push.
AnswerB

This merges the latest main (with bug fixes) into the feature branch, keeping the work isolated.

Why this answer

Merging the main branch into the feature branch (git checkout new-feature, git merge main) brings the fixes into Alice's branch. The opposite (merging feature into main) would add unfinished work to main. Rebasing with force push is dangerous.

Creating a new branch doesn't bring in fixes.

44
MCQmedium

A company is developing a mobile app and wants to ensure it works on both iOS and Android without writing separate codebases. Which approach should be used?

A.Cross-platform development
B.Native development
C.Web-based development
D.Cloud-based development
AnswerA

Cross-platform frameworks like React Native allow one codebase for multiple platforms.

Why this answer

Option A is correct because cross-platform development allows a single codebase to run on multiple platforms. Option B (native) requires separate code; Option C (web-based) may not provide native features; Option D (cloud-based) offloads processing but isn't about platform independence.

45
MCQmedium

During the software development life cycle, which phase directly follows the coding phase?

A.Maintenance
B.Testing
C.Deployment
D.Requirements gathering
AnswerB

Testing is the phase after coding to verify functionality.

Why this answer

The correct answer is B: Testing. After coding, the software is tested to identify defects. Requirements (A) come before coding.

Deployment (C) and maintenance (D) occur after testing.

46
MCQeasy

A junior developer is tasked with fixing a bug where a variable is unexpectedly undefined. The developer suspects the variable is not within scope. Which programming concept describes where a variable can be accessed?

A.Loop
B.Scope
C.Data type
D.Function
AnswerB

Scope determines the visibility and lifetime of a variable within a program.

Why this answer

Scope is the programming concept that defines the region of code where a variable is accessible. If a variable is unexpectedly undefined, it is often because it was declared outside the current block or function, making it out of scope. In JavaScript, for example, variables declared with `let` or `const` inside a block are not accessible outside that block.

Exam trap

The trap here is that candidates confuse 'function' (a code block) with 'scope' (the accessibility region), thinking that simply being inside a function guarantees access, when in reality scope is determined by declaration location and keyword (e.g., `var` vs `let`).

How to eliminate wrong answers

Option A is wrong because a loop is a control structure for repeating code, not a concept that determines variable accessibility. Option C is wrong because a data type defines what kind of value a variable holds (e.g., string, number), not where it can be accessed. Option D is wrong because a function is a reusable block of code, but scope is the broader concept that includes function scope, block scope, and global scope.

47
MCQhard

A web application uses a JavaScript function to validate user input on a registration form. The function checks that the password is at least 8 characters long and contains a number. When a user submits the form with a password "abc123", the validation passes even though the password has only 6 characters. The developer examines the code and finds that the function uses the condition: if (password.length >= 8 || /\d/.test(password)). Which logical error is causing this bug?

A.The condition uses OR instead of AND.
B.The function is not called.
C.The regular expression is incorrect.
D.The length check is incorrect because it uses >= instead of >.
AnswerA

Using OR means only one condition needs to be true; with AND both must be true.

Why this answer

The condition uses OR (||) instead of AND (&&), so the validation passes if either condition is true. "abc123" has a number, so it passes. The regular expression is correct, length check is appropriate, and the function is called.

48
MCQeasy

A developer sees the above error message. What type of error is this?

A.Syntax error
B.Compile error
C.Logic error
D.Runtime error
AnswerD

NullReferenceException occurs at runtime when an object is null.

Why this answer

The correct answer is C: Runtime error. NullReferenceException occurs during program execution when trying to access an object that is null. Syntax errors (A) are caught at compile time.

Compile errors (B) prevent compilation. Logic errors (D) produce wrong results but no exception.

49
MCQhard

A developer accidentally committed a bug that broke the build. The team wants to undo the commit without losing the commit history. Which Git command should be used?

A.git reset HEAD~1
B.git checkout HEAD~1
C.git revert HEAD
D.git branch -d bugfix
AnswerC

git revert creates a new commit that undoes the changes, keeping history intact.

Why this answer

The correct answer is D: git revert. It creates a new commit that undoes the changes, preserving history. git reset (A) removes commits and rewrites history, which is problematic for shared branches. git checkout (B) switches branches or restores files. git branch (C) manages branches.

50
MCQmedium

A programmer needs to store a true/false value. Which data type is most appropriate?

A.Integer
B.String
C.Boolean
D.Float
AnswerC

Boolean is specifically designed for true/false values.

Why this answer

The correct answer is B: Boolean. Boolean data type stores true/false values. Integer (A) stores whole numbers.

String (C) stores text. Float (D) stores decimal numbers.

51
Multi-Selecthard

Which THREE are valid primitive data types in most programming languages? (Choose three.)

Select 3 answers
A.String
B.Character
C.Boolean
D.Integer
E.Array
AnswersB, C, D

Character is a primitive type.

Why this answer

The correct answers are A, C, and D: Integer, Boolean, and character. String (B) is not primitive in many languages (it's an object). Array (E) is a composite type.

52
MCQeasy

A junior developer is tasked with creating a function that checks whether a number is even or odd. The developer writes the following pseudocode: FUNCTION isEven(number) IF number % 2 == 0 THEN RETURN true ELSE RETURN false. The developer then realizes they need to handle non-integer input. Which of the following should the developer add to improve the robustness of this function?

A.Add input validation to check if the number is an integer.
B.Delete the function and use a built-in library instead.
C.Change the modulus operator to a division operator.
D.Add a parameter for the number type.
AnswerA

Validation ensures only integers are processed, preventing errors.

Why this answer

Adding input validation to check if the number is an integer ensures the modulus operation works correctly. A parameter for number type is not standard. Changing the operator would break the logic.

Deleting and using a library is overkill.

53
MCQhard

A developer sees the above output. After a recent commit, the application crashed due to a null pointer. Which commit likely introduced the null pointer issue?

A.def456
B.abc123
C.012jkl
D.789ghi
AnswerA

The null pointer bug likely originated in the new feature commit def456.

Why this answer

The correct answer is C: def456. The null pointer was fixed in 789ghi, so the bug was introduced before that. The initial commit (D) likely didn't have the bug.

The bug fix (A) fixes it. The fix commit shows 'Fixed bug', but the null pointer fix is 789ghi. So the commit that introduced it is def456.

Wait: The exhibit shows: abc123 fixed bug, def456 added feature, 789ghi fixed null pointer, 012jkl initial. So the null pointer was fixed in 789ghi. It was introduced in the commit before that? Usually the bug is introduced in a prior commit.

The question asks: 'After a recent commit, the application crashed due to a null pointer.' Which commit likely introduced the null pointer? Since it was fixed in 789ghi, it was likely introduced in def456 (the addition of new feature). So correct answer is B: def456. But options: A abc123, B def456, C 789ghi, D 012jkl.

Correct is B.

54
Multi-Selecteasy

Which TWO of the following are primitive data types commonly used in programming?

Select 2 answers
A.String
B.Integer
C.Boolean
D.Array
E.Function
AnswersB, C

Integer is a primitive numeric data type.

Why this answer

Integer and Boolean are primitive data types. Array and String are composite or reference types. Function is not a data type.

55
Multi-Selecthard

Which THREE of the following are characteristics of object-oriented programming (OOP)? (Select THREE).

Select 3 answers
A.Polymorphism
B.Encapsulation
C.Inheritance
D.Top-down design
E.Sequential execution
AnswersA, B, C

Polymorphism allows objects to be treated as instances of their parent class.

Why this answer

Polymorphism is a core OOP concept that allows objects of different classes to be treated as objects of a common superclass, with method calls resolved at runtime based on the actual object type. This enables one interface to be used for a general class of actions, with specific behavior determined by the specific object instance.

Exam trap

CompTIA often tests the distinction between OOP principles (encapsulation, inheritance, polymorphism) and procedural or structured programming concepts (top-down design, sequential execution), so candidates mistakenly select familiar-sounding terms like 'top-down design' without recognizing they belong to a different paradigm.

56
Drag & Dropmedium

Drag and drop the steps to uninstall a program in Windows 10 into the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order

Why this order

Uninstalling programs removes them from the system to free up space.

57
MCQeasy

A developer writes the following pseudocode: for i = 1 to 5, sum = sum + i. What does this code do?

A.It sums the numbers from 1 to 5
B.It adds 5 to the sum
C.It multiplies numbers from 1 to 5
D.It prints the numbers from 1 to 5
AnswerA

The loop iterates through 1 to 5 and accumulates the sum.

Why this answer

The correct answer is C: It sums the numbers from 1 to 5. The loop runs i from 1 to 5, adding each to sum. Option A (adds 5 to sum) is incorrect because i takes multiple values.

Option B (multiplies numbers) uses '+' not '*'. Option D (prints numbers) doesn't involve output.

58
Drag & Dropmedium

Drag and drop the steps to create a new folder on the desktop in Windows 10 into the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order

Why this order

Creating a folder uses the right-click context menu, then naming it.

59
MCQhard

A team is developing a new feature using an Agile methodology. The product owner wants to see a working version of the feature after each iteration. Which practice best supports this request?

A.Code review
B.Continuous integration
C.Refactoring
D.Writing comprehensive documentation
AnswerB

Continuous integration ensures that code changes are integrated and built frequently, providing a working version.

Why this answer

Continuous integration (CI) is the practice of automatically merging and testing code changes frequently, often multiple times per day. This ensures that after each iteration (sprint), the team has a working, integrated version of the feature, directly supporting the product owner's request to see a functional build. CI relies on automated builds and tests to catch integration issues early, enabling rapid feedback and delivery.

Exam trap

The trap here is that candidates may confuse 'continuous integration' with 'code review' or 'refactoring,' thinking that any quality practice supports iterative delivery, but only CI directly ensures a working integrated build after each iteration.

How to eliminate wrong answers

Option A is wrong because code review focuses on manual inspection of code quality and logic, not on producing a working integrated version after each iteration; it does not automate the build or test process. Option C is wrong because refactoring is the process of restructuring existing code without changing its external behavior, aimed at improving maintainability, not at delivering a working feature increment. Option D is wrong because writing comprehensive documentation, while valuable for knowledge transfer, does not produce a working software version; it is a separate activity that can delay or distract from iterative delivery.

60
Matchingmedium

Match each cloud service model to its description.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Virtual machines and storage

Platform for app development

Software accessed via browser

Virtual desktop infrastructure

Why these pairings

Cloud service delivery models.

61
Multi-Selecteasy

Which THREE are phases of the software development life cycle? (Choose three.)

Select 3 answers
A.Marketing
B.Planning
C.Deployment
D.Debugging
E.Coding
AnswersB, C, E

Planning is the initial SDLC phase.

Why this answer

The correct answers are A, B, and D: Planning, coding, and deployment. Debugging (C) is part of testing. Marketing (E) is not an SDLC phase.

62
Multi-Selectmedium

Which TWO of the following are characteristics of the Agile software development methodology?

Select 2 answers
A.Emphasis on detailed upfront planning
B.Heavy documentation
C.Rigid change control
D.Customer collaboration
E.Iterative development cycles
AnswersD, E

Agile promotes continuous customer involvement.

Why this answer

Agile emphasizes iterative development and customer collaboration, not upfront planning or heavy documentation.

63
MCQmedium

A development team is using version control for their project. They need to isolate a new feature from the main codebase until it is complete. Which version control operation should they perform?

A.Merge
B.Commit
C.Branch
D.Push
AnswerC

Branching creates a separate workspace for developing a feature independently.

Why this answer

Branching creates a separate line of development within a version control system (e.g., Git, Mercurial), allowing the team to work on a new feature in isolation without affecting the main codebase (often called 'main' or 'master'). Once the feature is complete and tested, the branch can be merged back. This directly addresses the requirement to isolate work until it is finished.

Exam trap

CompTIA often tests the misconception that 'commit' or 'push' can isolate work, but these operations only record or share changes; they do not create a separate development path, which is the core purpose of a branch.

How to eliminate wrong answers

Option A is wrong because a merge combines changes from two branches (e.g., a feature branch into main) and is used after the feature is complete, not to isolate it. Option B is wrong because a commit saves a snapshot of changes to the local repository but does not create a separate workspace or isolate the feature from the main codebase. Option D is wrong because a push uploads local commits to a remote repository (e.g., GitHub, GitLab) but does not provide isolation; it simply shares existing changes.

64
MCQeasy

A developer needs to store a list of student grades (integers) and be able to add and remove grades easily. Which data structure is most appropriate?

A.Array
B.Linked list
C.Queue
D.Stack
AnswerA

Arrays allow random access and easy addition/removal (in dynamic arrays).

Why this answer

Option A is correct because an array is a simple ordered list that supports dynamic resizing in many languages (like Python list). Option B (linked list) is more complex; Option C (stack) restricts to LIFO; Option D (queue) restricts to FIFO.

65
MCQeasy

A developer needs to repeat a set of instructions exactly 10 times. Which programming construct should be used?

A.For loop
B.Variable
C.Function
D.If-else statement
AnswerA

A for loop is designed for iterating a specific number of times.

Why this answer

A for loop is the correct construct because it is specifically designed to execute a block of code a predetermined number of times, such as exactly 10 iterations. The loop's initialization, condition, and increment/decrement components allow precise control over the repetition count, making it ideal for this requirement.

Exam trap

CompTIA often tests the distinction between iteration (loops) and selection (conditionals), so the trap here is that candidates may confuse an if-else statement with a loop, thinking it can repeat instructions by nesting, but it cannot inherently iterate a fixed number of times.

How to eliminate wrong answers

Option B is wrong because a variable is a named storage location for data, not a control structure for repeating instructions. Option C is wrong because a function is a reusable block of code that executes when called, but it does not inherently repeat instructions a fixed number of times without additional looping logic. Option D is wrong because an if-else statement is a conditional construct that executes code based on a boolean condition, not a mechanism for repetition.

66
MCQmedium

A software team is developing a mobile payment application using the waterfall model. They have completed the requirements, design, and implementation phases. During system testing, testers discover that the app crashes when processing transactions over $10,000. Further investigation reveals that the design specification for the transaction module did not account for large amounts, causing an overflow error. The project manager holds a meeting to decide the next steps. The team estimates that fixing the issue will require redesigning the transaction module, updating the code, and retesting, which will add two weeks to the schedule. The client's contract includes a penalty for late delivery but also a clause requiring the software to be free of critical defects. The team has already used most of the contingency time. What is the BEST course of action?

A.Switch to an agile methodology immediately and iterate on the fix without formal approval.
B.Submit a formal change request to the change control board to approve a redesign of the transaction module.
C.Ignore the issue because only a few transactions exceed $10,000, and hope testers overlook it.
D.Continue with current implementation and patch the crash after release as a maintenance update.
AnswerB

This follows the waterfall process and addresses the defect properly, even if it delays the project.

Why this answer

Submitting a formal change request follows the waterfall process and protects the team from blame, while addressing a critical defect.

67
MCQeasy

A junior developer is creating a script to generate reports for each of 10 departments. The script should run the report generation code exactly 10 times. Which control structure should be used?

A.for loop
B.while loop
C.if-else
D.switch
AnswerA

A for loop is designed for definite iteration over a range or collection.

Why this answer

A for loop is the best choice for iterating a fixed number of times. A while loop could work but is less clear for definite iteration. if-else and switch are conditional structures, not iterative.

68
MCQmedium

An administrator reviews the above policy. What does it do?

A.It denies delete access to the bucket for requests from the 192.0.2.0/24 IP range
B.It allows delete access to the bucket for all IPs
C.It allows read access to the bucket from the IP range
D.It denies all s3 actions to the bucket
AnswerA

The policy explicitly denies s3:DeleteObject for the specified IP range.

Why this answer

The correct answer is B: It denies delete access to the bucket for requests coming from the 192.0.2.0/24 IP range. The effect is Deny, action is s3:DeleteObject, resource is my-bucket, condition restricts to IP range. Option A (allows delete) contradicts effect.

Option C (denies all actions) is incorrect because only delete is specified. Option D (allows read) is wrong.

69
MCQmedium

A team is using version control for a software project. A developer accidentally committed a buggy change to the main branch. Which action should the team take to fix this while preserving the commit history?

A.Ask all developers to manually undo the changes in their local copies.
B.Use the revert command to create a new commit that undoes the changes.
C.Delete the repository and start over.
D.Force delete the commit from history.
AnswerB

Revert safely undoes changes while preserving the existing commit history.

Why this answer

Revert creates a new commit that undoes the changes, maintaining history. Deleting the repository or forcing a history rewrite are risky and not standard practice. Manual undo by all developers is inefficient and error-prone.

70
Multi-Selectmedium

Which TWO are characteristics of object-oriented programming? (Choose two.)

Select 2 answers
A.Inheritance
B.Loops
C.Functions
D.Variables
E.Encapsulation
AnswersA, E

Inheritance is a key OOP concept.

Why this answer

The correct answers are B and C: Inheritance and encapsulation. Inheritance allows classes to derive from others; encapsulation bundles data and methods. Loops (A) are not OOP-specific.

Functions (D) are procedural. Variables (E) are generic.

71
Multi-Selectmedium

Which TWO of the following are examples of high-level programming languages? (Select TWO).

Select 2 answers
A.Machine code
B.Assembly
C.Python
D.Java
E.Binary
AnswersC, D

Python is a high-level language with strong abstraction.

Why this answer

Python and Java are both high-level programming languages because they provide strong abstraction from the computer's hardware, using human-readable syntax and automatic memory management. Python is interpreted and dynamically typed, while Java is compiled to bytecode and statically typed, but both allow developers to write code without managing registers or memory addresses directly.

Exam trap

CompTIA often tests the distinction between 'high-level' and 'low-level' languages, and the trap here is that candidates confuse 'binary' or 'machine code' with a programming language, or think assembly is high-level because it uses readable mnemonics.

72
MCQhard

A software team uses version control and one developer commits a change that breaks the build. Which practice should be enforced to prevent this in the future?

A.Schedule daily automated builds
B.Require peer review for all commits
C.Implement a code freeze during releases
D.Set up a pre-commit hook to run unit tests
AnswerD

Pre-commit hooks automatically run tests, rejecting commits that break them.

Why this answer

Option C is correct because a pre-commit hook can automatically run tests before allowing a commit. Option A (code freeze) is too restrictive; Option B (peer review) helps but doesn't automatically prevent; Option D (daily builds) doesn't catch issues before commit.

73
MCQhard

You are a junior developer at a small company that uses a monolithic web application written in Python. The application runs on a single server and uses a MySQL database. Recently, the application has become slow during peak hours. The operations team reports high CPU usage on the server. You suspect that the database queries are not optimized. You propose to refactor the application to use a caching layer. However, your manager is concerned about adding complexity and suggests that you first optimize the most frequently executed queries. You review the code and find that the most frequent query selects all columns from a large table without a WHERE clause. The table has over 1 million rows. Which course of action should you take?

A.Implement a caching layer using Redis.
B.Upgrade the server to have more CPU and RAM.
C.Add an index on all columns used in the query.
D.Modify the query to include a WHERE clause that filters on an indexed column.
AnswerD

Adding a WHERE clause reduces the amount of data retrieved, improving performance.

Why this answer

Option D is correct because the query selects all columns from a large table without a WHERE clause, which forces a full table scan. Adding a WHERE clause that filters on an indexed column reduces the number of rows scanned, dramatically improving performance without introducing the complexity of a caching layer. This directly addresses the high CPU usage caused by inefficient query execution.

Exam trap

The trap here is that candidates assume adding an index always speeds up any query, but without a WHERE clause, an index is never used—the database still must scan the entire table.

How to eliminate wrong answers

Option A is wrong because implementing a caching layer (e.g., Redis) adds architectural complexity and does not fix the root cause—the unoptimized query itself; caching would only mask the problem and could lead to stale data issues. Option B is wrong because upgrading hardware (more CPU/RAM) treats the symptom (high CPU usage) rather than the cause (inefficient query), and it is a costly, temporary fix that does not improve query logic. Option C is wrong because adding an index on all columns used in the query is meaningless for a SELECT * without a WHERE clause—indexes speed up row filtering, not full table scans; the query still retrieves every row, so no index can help.

74
Multi-Selecthard

A developer is debugging a program that is producing incorrect output. Which of the following are common debugging techniques? (Choose three.)

Select 3 answers
A.Using a debugger
B.Code review
C.Adding print statements
D.Reinstalling the operating system
E.Changing the program requirements
AnswersA, B, C

Debuggers allow stepping through code and inspecting state.

Why this answer

Common debugging techniques include adding print statements, using a debugger, and performing code reviews. Changing requirements or reinstalling the OS are not debugging techniques.

75
MCQmedium

Refer to the exhibit. A developer wrote this BASIC program. What will happen if the user presses Enter without typing a name?

A.The program will print "Hello, " with no name.
B.The program will display an error message.
C.The program will prompt for input again.
D.The program will end with no output.
AnswerC

The GOTO 10 sends execution back to the input prompt.

Why this answer

In BASIC, the INPUT statement reads a string from the user. If the user presses Enter without typing a name, the variable receives an empty string (""). The program then prints "Hello, " followed by that empty string, resulting in "Hello, " with no name.

Option C is incorrect because the program does not loop or re-prompt; it simply continues with the empty string.

Exam trap

The trap here is that candidates may assume an empty input causes an error or no output, but BASIC's INPUT statement treats an empty input as a valid empty string, so the program runs normally and prints "Hello, " with no name.

How to eliminate wrong answers

Option A is wrong because the program will indeed print "Hello, " with no name, not an error. Option B is wrong because BASIC's INPUT statement does not generate an error for an empty input; it accepts an empty string as valid. Option D is wrong because the program does produce output: it prints "Hello, " followed by the empty string, so there is output.

Page 1 of 2 · 80 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Software Dev Concepts questions.