Software Engineering part 1 Flashcards

(21 cards)

1
Q

What are the principles of test-driven development?

A

Building tests first to improve code quality and early bug detection

TDD emphasizes writing tests before code implementation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the importance of unit testing?

A

Ensures code quality, facilitates debugging, and improves design

Unit testing helps in verifying the functionality of specific sections of code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the key methods and annotations used in JUnit testing?

A
  • @Test
  • @RepeatedTest
  • @ParameterizedTest

These annotations help in defining test methods and their behaviors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the unit test life cycle?

A
  • setUp()
  • tearDown()

These methods are used to prepare the testing environment and clean up afterwards.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the @Test annotation in JUnit?

A

Identifies a method as a test method

It marks methods that will contain the actual test cases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Defensive Programming?

A

Anticipating errors and handling potential sources of problems

This approach helps in writing code that is robust and less prone to failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two types of exceptions in Java?

A
  • Checked exceptions
  • Unchecked exceptions

Checked exceptions must be handled or declared, while unchecked exceptions do not require explicit handling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the throw keyword in Java?

A

Used to throw an exception

It allows you to explicitly raise an exception in your code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an enum type in Java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between a List and a Set in Java?

A

List allows duplicates and maintains order; Set does not allow duplicates

Lists can have repeated elements, while Sets only contain unique elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the difference between HashSet and TreeSet?

A
  • HashSet: implemented using hash tables, unordered
  • TreeSet: implemented using binary search trees, ordered

TreeSets maintain a sorted order of elements, while HashSets do not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do you understand by the term ‘software process’?

A

A set of activities required to develop a software system

Software processes include specification, design, implementation, validation, and evolution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between centralized and distributed version control?

A
  • 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill in the blank: The method _______ is used to set up the test environment in JUnit.

A

setUp()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False: Unchecked exceptions are typically caused by external factors.

A

False

Unchecked exceptions usually arise from programming errors, not external issues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the key activities in a software development process?

A
  • Specification
  • Design and Implementation
  • Validation
  • Evolution

These activities ensure that the software meets user requirements and adapts to change.

17
Q

What is the role of Iterators in Java Collections?

A

To cycle through a collection to obtain or remove elements

Iterators provide a way to traverse through a collection without exposing its underlying structure.

18
Q

What is the purpose of the finally block in exception handling?

A

Always executed, used for clean-up code

It ensures that necessary clean-up actions are performed regardless of whether an exception occurred.

19
Q

How do you declare a custom exception in Java?

A

By extending the Exception class

Custom exceptions provide specific error handling mechanisms tailored to your application.

20
Q

What is the significance of boundary testing in TDD?

A

To ensure code works for first, last, and middle items

Boundary testing helps identify edge cases that might cause errors.