Software Engineering part 1 Flashcards
(21 cards)
What are the principles of test-driven development?
Building tests first to improve code quality and early bug detection
TDD emphasizes writing tests before code implementation.
What is the importance of unit testing?
Ensures code quality, facilitates debugging, and improves design
Unit testing helps in verifying the functionality of specific sections of code.
What are the key methods and annotations used in JUnit testing?
- @Test
- @RepeatedTest
- @ParameterizedTest
These annotations help in defining test methods and their behaviors.
What is the unit test life cycle?
- setUp()
- tearDown()
These methods are used to prepare the testing environment and clean up afterwards.
What is the purpose of the @Test annotation in JUnit?
Identifies a method as a test method
It marks methods that will contain the actual test cases.
What is Defensive Programming?
Anticipating errors and handling potential sources of problems
This approach helps in writing code that is robust and less prone to failure.
What are the two types of exceptions in Java?
- Checked exceptions
- Unchecked exceptions
Checked exceptions must be handled or declared, while unchecked exceptions do not require explicit handling.
What is the purpose of the throw keyword in Java?
Used to throw an exception
It allows you to explicitly raise an exception in your code.
What is an enum type in Java?
A special data type that allows a variable to be a set of predefined constants
Enums are useful for representing a fixed set of values.
What is the difference between a List and a Set in Java?
List allows duplicates and maintains order; Set does not allow duplicates
Lists can have repeated elements, while Sets only contain unique elements.
What is the difference between HashSet and TreeSet?
- HashSet: implemented using hash tables, unordered
- TreeSet: implemented using binary search trees, ordered
TreeSets maintain a sorted order of elements, while HashSets do not.
What do you understand by the term ‘software process’?
A set of activities required to develop a software system
Software processes include specification, design, implementation, validation, and evolution.
What is the difference between centralized and distributed version control?
- Centralized: repository on a server
- Distributed: everyone has a copy of the repository
Centralized systems depend on a single server, while distributed systems allow multiple copies.
Fill in the blank: The method _______ is used to set up the test environment in JUnit.
setUp()
True or False: Unchecked exceptions are typically caused by external factors.
False
Unchecked exceptions usually arise from programming errors, not external issues.
What are the key activities in a software development process?
- Specification
- Design and Implementation
- Validation
- Evolution
These activities ensure that the software meets user requirements and adapts to change.
What is the role of Iterators in Java Collections?
To cycle through a collection to obtain or remove elements
Iterators provide a way to traverse through a collection without exposing its underlying structure.
What is the purpose of the finally block in exception handling?
Always executed, used for clean-up code
It ensures that necessary clean-up actions are performed regardless of whether an exception occurred.
How do you declare a custom exception in Java?
By extending the Exception class
Custom exceptions provide specific error handling mechanisms tailored to your application.
What is the significance of boundary testing in TDD?
To ensure code works for first, last, and middle items
Boundary testing helps identify edge cases that might cause errors.