First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Desarrollo de software
In object-oriented design, which principle states that a class should have only one reason to change?
- Single Responsibility Principle Correct answer.
- Liskov Substitution Principle
- Open/Closed Principle
- Interface Segregation Principle
Explanation
The Single Responsibility Principle assigns each class exactly one axis of change, so modifications for one concern do not ripple into others. The other SOLID principles address extension without modification, subtype substitutability, and client-specific interfaces respectively.
Question 2Desarrollo de software
Which data structure provides last-in, first-out (LIFO) access?
- Hash table
- Linked list
- Queue
- Stack Correct answer.
Explanation
A stack pushes and pops at the same end, so the most recently added element is removed first. Queues are first-in, first-out, while linked lists and hash tables do not impose LIFO ordering by themselves.
Question 3Desarrollo de software
A developer writes a unit test that must verify that calling a payment function with a negative amount raises an exception. Which test structure best expresses this intent?
- Arrange the account, act by calling the function with a negative amount, assert that an exception is raised Correct answer.
- Act by calling the function, arrange the account, assert the return value is zero
- Arrange a mock gateway, assert the exception, act by constructing the account
- Assert the balance is unchanged, act by calling the function, arrange a mock gateway
Explanation
Unit tests follow arrange-act-assert order: set up state, invoke the behavior under test, then verify the expected outcome. Verifying that the exception is raised belongs in the assert step after the call.
Question 4Desarrollo de software
Which HTTP status code family indicates that the client's request was malformed or cannot be fulfilled due to client error?
- 1xx
- 3xx
- 2xx
- 4xx Correct answer.
Explanation
The 4xx class signals client-side errors such as bad syntax or unauthorized access. The 1xx, 2xx, and 3xx classes cover informational, success, and redirection outcomes.
Question 5Desarrollo de software
Which version control operation integrates changes from one branch into another while preserving a linear history by replaying commits?
- Merge
- Fetch
- Rebase Correct answer.
- Clone
Explanation
Rebase reapplies commits from one branch onto another, producing a linear sequence of commits. Merge instead creates a merge commit joining the two histories, while clone and fetch only copy or download objects.
Question 6Desarrollo de software
In a relational database, which SQL clause is used to filter rows after grouping and aggregation has been applied?
- GROUP BY
- HAVING Correct answer.
- ORDER BY
- WHERE
Explanation
HAVING filters grouped results after aggregation, so it can reference aggregate functions. WHERE filters individual rows before grouping, ORDER BY sorts output, and GROUP BY forms the groups.
Question 7Desarrollo de software
Which software development model delivers working software in short, iterative increments with continuous stakeholder feedback?
- V-model
- Waterfall
- Agile Correct answer.
- Big bang
Explanation
Agile methods organize work into short iterations that produce working increments and incorporate feedback continuously. Waterfall and the V-model are sequential with late verification, and big bang integrates everything at the end.
Question 8Desarrollo de software
Which characteristic of clean code most directly reduces the cost of maintaining a function over time?
- Using the maximum allowed line length
- Combining multiple responsibilities into one function
- Choosing descriptive names that reveal intent Correct answer.
- Minimizing the number of comments to zero
Explanation
Descriptive names communicate what code does, so maintainers spend less effort inferring intent. Long lines and zero comments do not improve clarity, and combining responsibilities increases coupling and complexity.
Question 9Desarrollo de software
A function accepts a list of integers and returns the largest value. For the input [3, 9, 2, 7], what does the function return if it initializes the maximum to the first element and then compares each remaining element?
- 9 Correct answer.
- 7
- 3
- 2
Explanation
Starting from the first element (3), the scan updates the maximum whenever a larger value is seen, reaching 9. The remaining values 2 and 7 are never larger than the running maximum.
Question 10Desarrollo de software
A binary search tree stores distinct integer keys. Which traversal visits the keys in ascending sorted order?
- Inorder Correct answer.
- Preorder
- Postorder
- Level order
Explanation
Inorder traversal visits the left subtree, then the node, then the right subtree, which yields ascending order for a binary search tree. Preorder and postorder place the node before or after both subtrees, and level order follows breadth.
Question 11Desarrollo de software
A web application stores user passwords in a database. Which practice best protects them if the database is compromised?
- Storing a slow salted hash produced by a password-hashing function Correct answer.
- Storing the passwords in a separate table with restricted permissions
- Storing a fast unsalted hash of each password
- Storing each password with a reversible symmetric encryption key
Explanation
Password-hashing functions such as bcrypt or Argon2 are deliberately slow and use per-user salts, which resists offline cracking and rainbow tables. Reversible encryption and fast unsalted hashes fail once the key or hash list is exposed.
Question 12Desarrollo de software
Which design pattern provides a way to create families of related objects without specifying their concrete classes?
- Factory Method
- Abstract Factory Correct answer.
- Builder
- Singleton
Explanation
Abstract Factory exposes an interface for creating families of related products, letting clients work with concrete classes indirectly. Factory Method creates a single product, Builder assembles a complex object step by step, and Singleton restricts instantiation to one instance.
Question 13Desarrollo de software
A team needs to add logging around existing method calls without editing the classes that declare those methods. Which technique fits this requirement?
- Making the methods private
- Inheriting from each class and overriding every method
- Marking the methods as static
- Using a dynamic proxy that intercepts calls and delegates to the target Correct answer.
Explanation
A dynamic proxy implements the same interface, adds behavior such as logging, and forwards the call to the real object without modifying it. Inheritance requires editing subclasses per class, and static or private modifiers do not add cross-cutting behavior.
Question 14Desarrollo de software
Given the relational schema Student(id, name) and Enrollment(student_id, course_id), which query returns students enrolled in no course?
- SELECT * FROM Student WHERE id NOT IN (SELECT student_id FROM Enrollment) Correct answer.
- SELECT * FROM Student JOIN Enrollment ON Student.id = Enrollment.student_id
- SELECT * FROM Student WHERE id = (SELECT student_id FROM Enrollment)
- SELECT * FROM Student WHERE id IN (SELECT student_id FROM Enrollment)
Explanation
A NOT IN (or NOT EXISTS) subquery over Enrollment selects students whose id never appears as an enrollment. The IN form returns enrolled students, the join returns matching rows, and the equality subquery compares against a possibly multi-row result.
Question 15Desarrollo de software
Which REST design choice is most consistent with HTTP semantics for updating a resource's full representation?
- POST /resources/{id}/update with the new state
- DELETE /resources/{id} with query parameters for the new state
- GET /resources/{id} with a body containing the new state
- PUT /resources/{id} with the complete new representation Correct answer.
Explanation
PUT replaces the resource at the given URI with the supplied full representation and is idempotent. GET must be safe and read-only, DELETE removes the resource, and the custom update action departs from standard semantics.
Question 16Desarrollo de software
In a continuous integration pipeline, which practice best catches integration defects early?
- Merging long-lived feature branches at the end of the quarter
- Running the full test suite only before each release
- Deploying directly to production without automated tests
- Running automated builds and tests on every commit Correct answer.
Explanation
Continuous integration builds and tests each commit, so integration problems surface while the change is small and easy to fix. Deferring tests or merging large branches late lengthens feedback loops and increases risk.
Question 17Desarrollo de software
A recursive function computes the nth Fibonacci number by calling itself twice per invocation. Which technique most improves its exponential time complexity?
- Increasing the recursion depth limit
- Reordering the two recursive calls
- Converting the function to use a loop with two running values Correct answer.
- Adding more base cases
Explanation
An iterative computation keeps only the last two values, reducing the work to linear time and constant space. Raising limits, adding base cases, or reordering calls does not remove the repeated recomputation that causes exponential growth.
Question 18Desarrollo de software
A developer must ensure that a shared counter is incremented safely by multiple threads. Which mechanism provides mutual exclusion for the critical section?
- A mutex lock around the increment Correct answer.
- A volatile variable declaration
- A comment documenting the race condition
- A larger integer type for the counter
Explanation
A mutex allows only one thread at a time into the critical section, preventing lost updates to the counter. Volatile affects visibility of writes but does not make read-modify-write atomic, and type size or comments do not provide exclusion.
Question 19Desarrollo de software
Which refactoring best removes a long conditional chain that selects behavior based on an object's type code?
- Adding more branches to cover additional type codes
- Replacing the conditional with polymorphic subclasses that implement the behavior Correct answer.
- Extracting the conditional into a separate method unchanged
- Renaming the type code variable to be more descriptive
Explanation
Replacing conditional logic with polymorphism lets each subtype supply its own behavior, so adding a new type does not require editing a growing branch chain. Adding branches, merely extracting the method, or renaming the variable leaves the structural problem intact.
Question 20Desarrollo de software
A test double is configured to return canned responses and to verify that a specific method was called with specific arguments. Which kind of test double is this?
- Stub
- Dummy
- Fake
- Mock Correct answer.
Explanation
A mock both supplies programmed responses and records interactions so the test can verify calls and arguments. A stub only returns canned values, a fake is a working simplified implementation, and a dummy is passed only to satisfy a parameter.
Question 21Desarrollo de software
In a code review, a reviewer finds a method that queries a database, formats output, and sends email. Which design issue is most evident?
- The method violates cohesion by mixing unrelated responsibilities Correct answer.
- The method has too many parameters
- The method uses recursion without a base case
- The method is immutable
Explanation
Persistence, presentation, and notification are distinct concerns, so combining them in one method lowers cohesion and raises coupling. The scenario describes responsibilities, not parameter count, recursion, or immutability.
Question 22Desarrollo de software
A service must be idempotent under retries. Which operation design satisfies this requirement when a client retries after a network timeout?
- Updating a record to a fixed target state keyed by a client-supplied idempotency key Correct answer.
- Creating a new order each time the endpoint is called
- Incrementing a counter on every call
- Appending a new log entry on every call
Explanation
An idempotency key lets the service recognize a retried request and return the original result without applying the change twice. Creating, appending, or incrementing on every call applies the effect repeatedly under retries.
Question 23Desarrollo de software
Two transactions each hold a lock on a different row and each requests the row locked by the other. Which condition describes this situation?
- A dirty read caused by uncommitted data
- A phantom read caused by range queries
- A deadlock caused by circular waiting Correct answer.
- A livelock caused by repeated retries
Explanation
Each transaction waits for a lock held by the other, forming a circular wait that neither can break without intervention. Livelock involves repeated state changes without progress, while dirty and phantom reads are isolation anomalies rather than lock cycles.
Question 24Desarrollo de software
A system must scale reads while tolerating stale data briefly. Which consistency approach best matches this requirement?
- Eventual consistency with asynchronous replication to read replicas Correct answer.
- Strong consistency with synchronous replication to all replicas
- Two-phase commit across all replicas for every read
- Serializable isolation for every query
Explanation
Eventual consistency with asynchronous replication allows reads to be served by replicas and accepts a short staleness window in exchange for scalability. Strong synchronous replication, two-phase commit, and serializable isolation all impose coordination that limits read scaling.
Question 25Desarrollo de software
A legacy module has no automated tests. Which strategy best enables safe refactoring while preserving behavior?
- Removing the module's public interface to reduce coupling
- Adding characterization tests that capture current observable behavior Correct answer.
- Freezing the module and never changing it
- Rewriting the module from scratch before any tests exist
Explanation
Characterization tests record the module's current behavior, providing a safety net that reveals unintended changes during refactoring. Rewriting without tests or freezing the module avoids the goal, and removing the interface breaks callers.
Question 26Desarrollo de software
Which software development life cycle model is best suited to projects where requirements are well understood and stable, and where formal documentation and phase gates are required?
- Waterfall Correct answer.
- Scrum
- Extreme Programming
- Prototyping
Explanation
The waterfall model proceeds through sequential phases with formal baselines and reviews, so it fits stable requirements and documentation-heavy environments. Agile approaches such as Scrum and Extreme Programming assume changing requirements and favor adaptation over phase gates.
Question 27Desarrollo de software
Which version control operation creates a new branch that shares history with the current branch but keeps subsequent commits isolated?
- git branch Correct answer.
- git rebase
- git merge
- git stash
Explanation
Creating a branch records a new pointer to the current commit, so later commits on that branch do not affect the original branch until they are integrated. Merging and rebasing are integration operations, and stashing only shelves uncommitted changes.
Question 28Desarrollo de software
A function is declared as `int sum(int a, int b)` in C. What does the return type of this declaration specify?
- The storage class of the function's local variables
- The number of parameters accepted
- The type of value the function returns to its caller Correct answer.
- The visibility of the function to other translation units
Explanation
In a C function declaration, the type before the function name states the type of the value produced by the function. Parameter count is determined by the parameter list, storage class by keywords such as static, and linkage by extern or static.
Question 29Desarrollo de software
A developer writes a unit test that must verify a function returns an error when given an empty list. Which test-design element is most important for making the test meaningful?
- A print statement that displays the input list
- A global variable shared with other tests
- A comment describing the purpose of the test
- An assertion that checks the returned error against the expected error Correct answer.
Explanation
A test is meaningful only if it asserts the expected observable outcome, here the specific error, so a failure is detected automatically. Printing, commenting, or sharing state does not verify behavior and can hide or couple defects.
Question 30Desarrollo de software
A team wants to replace a tightly coupled call from class A to a concrete class B with a dependency on an interface, so that B can be swapped. Which principle does this change most directly support?
- Law of Demeter
- Interface segregation principle
- Dependency inversion principle Correct answer.
- Single responsibility principle
Explanation
Depending on an abstraction instead of a concrete implementation is the dependency inversion principle, which decouples high-level policy from low-level detail. Single responsibility concerns reasons to change, the Law of Demeter concerns knowledge of object structure, and interface segregation concerns splitting fat interfaces.
Question 31Desarrollo de software
A REST API returns a list of 10,000 records in one response, causing slow clients. Which change best follows HTTP semantics to address this?
- Return the full list but compress it with gzip
- Support pagination with limit and offset parameters and link headers Correct answer.
- Return only the first 100 records and silently drop the rest
- Require clients to use POST to fetch the list
Explanation
Pagination with limit and offset, plus link headers for navigation, keeps responses bounded while staying within HTTP's resource-oriented model. Compression reduces size but still transfers all records, and silently truncating results violates client expectations.
Question 32Desarrollo de software
A developer must ensure that a critical section updating shared state is executed by only one thread at a time. Which synchronization primitive provides mutual exclusion for that section?
- A read-write lock used only for reads
- A semaphore initialized to zero
- A condition variable
- A mutex lock Correct answer.
Explanation
A mutex provides mutual exclusion by allowing only the thread that holds the lock to enter the critical section. A zero-initialized semaphore blocks waiters, condition variables signal about state changes, and a read-only lock permits concurrent readers instead of excluding them.
Question 33Desarrollo de software
A module contains a class with methods that read a file, parse its contents, compute statistics, and write a report. Which refactoring most directly improves cohesion and testability?
- Extract separate classes for reading, parsing, computing, and reporting Correct answer.
- Increase the visibility of internal fields to simplify access
- Merge the class with an unrelated utility class to reduce file count
- Add more public getters and setters to the class
Explanation
Extracting classes along the distinct responsibilities yields cohesive units that can be tested independently, which is the Single Responsibility Principle applied. Adding accessors, widening field visibility, or merging unrelated code increases coupling without separating concerns.
Question 34Desarrollo de software
An application must scale read traffic across replicas while tolerating brief staleness. Which consistency approach best matches this requirement?
- Strong consistency with synchronous replication to all nodes on every write
- Eventual consistency with asynchronous replica updates Correct answer.
- Serializable transactions across all replicas for every read
- Two-phase commit on every read operation
Explanation
Eventual consistency with asynchronous replication lets reads be served by replicas and scales read throughput while accepting temporary staleness. Strong or serializable consistency across all replicas adds coordination on every write or read, reducing availability and throughput.
Question 35Bases de datos
Which property of a relational transaction guarantees that once a change is committed it survives subsequent system failures?
- Consistency
- Durability Correct answer.
- Isolation
- Atomicity
Explanation
Durability is the ACID property ensuring committed changes are persisted, typically via write-ahead logging and stable storage. Atomicity concerns all-or-nothing execution, isolation concerns concurrent visibility, and consistency concerns valid state transitions.
Question 36Bases de datos
In an entity-relationship model, what does a cardinality constraint of many-to-many between two entity types describe?
- Each instance of one entity relates to at most one instance of the other
- Instances of one entity never relate to the other
- Instances of either entity may relate to multiple instances of the other Correct answer.
- Every instance must relate to exactly one instance of the other
Explanation
Many-to-many cardinality means an instance of either entity type can be associated with several instances of the other type. It is typically resolved into a junction (associative) table in the relational model.
Question 37Bases de datos
Which SQL clause is used to filter groups produced by GROUP BY based on an aggregate condition?
- HAVING Correct answer.
- DISTINCT
- ORDER BY
- WHERE
Explanation
HAVING applies predicates to grouped results after aggregation, so it can reference aggregate functions like COUNT or SUM. WHERE filters individual rows before grouping and cannot use aggregates for that purpose.
Question 38Bases de datos
Which normal form requires that every non-prime attribute depend on the whole candidate key rather than on part of a composite key?
- First normal form
- Third normal form
- Second normal form Correct answer.
- Boyce-Codd normal form
Explanation
Second normal form eliminates partial dependencies of non-prime attributes on part of a composite candidate key. First normal form addresses atomic values, while third and BCNF address transitive dependencies and every determinant being a superkey.
Question 39Bases de datos
A table has a column that stores a comma-separated list of phone numbers in a single cell. Which normal form does this most directly violate?
- Second normal form
- Fourth normal form
- First normal form Correct answer.
- Third normal form
Explanation
First normal form requires each attribute value to be atomic, and a comma-separated list is a repeating group inside one cell. The other normal forms presuppose 1NF and address dependencies among attributes.
Question 40Bases de datos
Which SQL statement removes all rows from a table while preserving the table structure and typically allowing the deletion to be rolled back when executed inside a transaction?
- DELETE FROM Correct answer.
- ALTER TABLE
- TRUNCATE TABLE
- DROP TABLE
Explanation
DELETE FROM removes rows and, in most engines, is logged and can be rolled back within a transaction. TRUNCATE is typically minimally logged and often cannot be rolled back, and DROP removes the table itself.
Question 41Bases de datos
What is the main purpose of an index on a database column?
- Reduce the time to locate rows matching a search condition Correct answer.
- Guarantee that values in the column are unique
- Enforce referential integrity between tables
- Compress the stored data to save disk space
Explanation
An index provides an auxiliary data structure, often a B-tree, that speeds up lookups and range scans on the indexed column. Uniqueness and referential integrity are enforced by constraints, not by indexes alone.
Question 42Bases de datos
In a relational database, what does a foreign key constraint enforce?
- That values in a column match values in a referenced key or are null Correct answer.
- That a column cannot contain null values
- That each row has a distinct primary key value
- That updates to a table are logged for recovery
Explanation
A foreign key requires each non-null value in the referencing column to exist in the referenced key, preserving referential integrity. Nulls are usually permitted unless a separate NOT NULL constraint applies.
Question 43Bases de datos
A query joins tables A and B on A.id = B.a_id and then filters with WHERE B.status = 'active'. If the filter is moved into the ON clause of a LEFT JOIN from A to B, how does the result change?
- Rows from A without any B are now excluded
- The results are identical in all cases
- The query becomes invalid because ON cannot contain non-equality conditions
- Rows from A without an active B are now retained with nulls Correct answer.
Explanation
With a LEFT JOIN, conditions in ON affect only which B rows match, so A rows with no active B are still returned with nulls. Placing the same predicate in WHERE would discard those null-extended rows.
Question 44Bases de datos
Two transactions run concurrently under a schedule that is conflict-serializable. Which statement must hold?
- Neither transaction may write any data item
- Both transactions must read the same data items
- The schedule produces the same result as some serial execution of the same transactions Correct answer.
- The schedule must avoid all lock waits
Explanation
Conflict serializability guarantees the concurrent schedule is equivalent to some serial order with respect to conflicting operations. It does not require read-only transactions or absence of lock waits.
Question 45Bases de datos
A transaction reads a row, another transaction updates and commits that row, and the first transaction reads it again and sees a different value. Which anomaly is this?
- Non-repeatable read Correct answer.
- Lost update
- Dirty read
- Phantom read
Explanation
A non-repeatable read occurs when a transaction re-reads a row and finds it changed by another committed transaction. Dirty reads involve uncommitted data, and phantoms involve new rows matching a predicate.
Question 46Bases de datos
Which isolation level prevents dirty reads but still permits non-repeatable reads according to the SQL standard?
- READ COMMITTED Correct answer.
- REPEATABLE READ
- SERIALIZABLE
- READ UNCOMMITTED
Explanation
READ COMMITTED only exposes data from committed transactions, so dirty reads are prevented, but a later read in the same transaction may see different committed values. REPEATABLE READ and SERIALIZABLE also prevent non-repeatable reads.
Question 47Bases de datos
A relation R(A, B, C) has functional dependencies A -> B and B -> C, with A the only candidate key. Which statement is true?
- R is in Boyce-Codd normal form
- R is in third normal form but not in Boyce-Codd normal form
- R is in second normal form but violates third normal form Correct answer.
- R has no functional dependencies on its key
Explanation
A is the only candidate key, so B and C are non-prime attributes. A -> B -> C creates a transitive dependency of C on A, violating third normal form, though no partial dependency exists so 2NF holds.
Question 48Bases de datos
What does the SQL GROUP BY clause do when combined with aggregate functions?
- It sorts the final result set by the grouping columns
- It removes duplicate values from a single column
- It restricts which rows participate before aggregation
- It collapses rows sharing grouping values into one output row per group Correct answer.
Explanation
GROUP BY partitions rows into groups sharing the same values in the grouping columns, and aggregates are computed per group. Row filtering before grouping is the role of WHERE, and sorting is done with ORDER BY.
Question 49Bases de datos
A developer needs to ensure that a column contains only values from a fixed set such as 'pending', 'shipped', or 'delivered'. Which mechanism best enforces this?
- A non-unique index on the column
- A default value of 'pending'
- A foreign key to the table's primary key
- A CHECK constraint on the column Correct answer.
Explanation
A CHECK constraint validates each row's value against a boolean predicate, restricting the column to the allowed set. Indexes, self-referencing foreign keys, and defaults do not restrict the domain of values.
Question 50Bases de datos
Which of the following best describes the difference between a clustered and a non-clustered index?
- A clustered index determines the physical order of rows, while a non-clustered index stores separate entries pointing to rows Correct answer.
- A non-clustered index is always faster for range scans than a clustered index
- A clustered index can only be built on a single column, while a non-clustered index can span many columns
- A clustered index does not consume additional storage
Explanation
A clustered index organizes the table's data by the index key, so the table can have only one, while a non-clustered index is a separate structure with pointers to rows. Both types can be composite and both consume storage.