Software Development Flashcards

1
Q

What does the SDLC represent?

A

The development of software as phases or sets of activities

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

What causes the SDLC?

A

The desire to define a predictable process to improve quality

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

What does the SDLC involve?

A

Creating processes that can be effectively managed

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

What are the 5 broad categories of the SDLC?

A
  1. Requirement Analysis
  2. Design
  3. Implementation
  4. Testing
  5. Evolution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Requirement Analysis?

A

What business/scientific problem is the system addressing?

What will the system do? Who are the users?

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

What is Design?

A

Hardware, software and network requirements

What parts are in-house, and what is externally developed or bought of the shelf

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

What is Implementation

A

The process of turning a software design into a working system by writing code, integrating components, and deploying it for use.

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

What is Testing?

A

The process of evaluating software to ensure it works as expected, is free of bugs, and meets user requirements.

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

What is Evolution?

A

Has system accomplished its goals, are there any modifications

Also includes maintenance of the system

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

What are the 4 Software Development Methodologies?

A
  1. Waterfall
  2. Prototyping
  3. Rapid Application Development
  4. Agile Development
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Waterfall?

A

Breaks process down into distinct sequential phases

  • Each phase needs sign-off before moving to the next
  • Leads to very well documented projects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Rapid Application Development?

A

Creating software quickly by focusing on speed, flexibility, and user feeback.
1. Fast Prototyping: quickly build small working versions
2. User involvement: give feedback on prototypes
3. Team improves software in short cycles
4. Skips heavy documentation and focuses on delivering functional features quickly

  • Often development deadline prioritised over requirements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Agile Development?

A

Where teams work in small steps called sprints, constantly adapt to change, and deliver results frequently. After each sprint teams reflect what went well, and get feedback. It focuses on collaboration, flexibility, and getting feedback to improve the product.

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

What is Prototyping?

A

Creating a simplified, working model of the software to test ideas, gather feedback, and refine before the final version is built.

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

What are the advantages of Agile Development

A
  1. User engagement
  2. Rapid Development of a usable product
  3. Early testing catches bugs and results in a high quality product
  4. Small incremental changes mitigate potential risk of introducing large change to system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a Scrum?

A

A framework within Agile development that organizes work into short, focused cycles called sprints (typically 2-4 weeks) to deliver small, workable software increments.

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

What is a Sprint planning meeting?

A

Part of a scrum that focuses on:

  1. Which items will be worked on
  2. Identify sprint tasks
  3. Divide the sprint into timeboxes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a Daily scrum meeting?

A

Part of a scrum that focuses on:

  1. Summarising previous day’s work and coming day’s work
  2. Intended to foster collaboration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a sprint review meeting?

A

A session where the team shows what they have built during a sprint

Part of a scrum that focuses on:
1. Showcase work: Team shows the features or improvements completed
2. Feedback time: Stakeholders give input on work
3. Adjust plans: Based on feedback, update priorities
4. Collaborative session: Everyone discusses what went well and what could be improved

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

What are the advantages of OOP?

A
  • Encapsulation/information hiding
  • Inheritance
  • Polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the difference with OOP in comparison to procedural programming?

A

Puts code into objects, in contrast to procedural programming where no relationships are defined for each entity.

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

What should classes in OOP include and how does encapsulation sometimes cause issues?

A
  • Should usually be specified to include only code related to their specific function.
  • Encapsulation can cause issues with tightly coupled classes that rely heavily on each other’s members.
    • This creates a lot of work in designing functions to access those - members.
  • These issues are more common in GUI programming.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Define a Nested Class

A

Classes defined within classes

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

What are two types of Nested Class?

A
  • Static nested class
  • Inner class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What modifiers can be used for standard outer classes and nested classes in Java?

A

Standard outer classes (top-level classes) can only be declared with two modifiers:
- public
- default (package-private)
Nested classes can be declared with any of the standard modifiers:
- public, private, protected, or package-private.

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

What is the main difference between Static Nested Class and Inner Class?

A

Static nested class (doesn’t have access to instance members)

Inner class (does have access to instance members)

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

Why use nested classes?

A
  • Closely linked classes can be located in one place for better organization.
  • If one class is only used by another, making it a nested class makes this relationship explicit.
  • Increases encapsulation by controlling visibility:
    • If the Engine class is nested inside the Car class, the private members of Car are visible to Engine.
  • Can also improve code readability.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

List 4 key features of Inner Classes

A
  • Can be difficult to spot in code
  • Will produce two class files on compilation
  • Inner classes can be directly accessed by the enclosing instance
  • All nested classes can be accessed externally through either the containing class or object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How does the scope with inner classes work?

A

“this” refers to the inner type instance

“OuterClass.this” refers to the instance of the surrounding (outer) class, when within the inner class code blocks.

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

What are local classes?

A

Local classes are defined and exist solely within a block (usually a method)

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

What can’t local class declaration contain?

A

Cannot contain public, protected, private, or static.

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

What can local classes access and not access?

A

Can access all members of outer class instance like standard inner class member

Cannot access method local variables unless they are declared as final

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

Define an anonymous class

A

Classes that are declared without any class name at all

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

How can anonymous classes be defined?

A

Not only may these be defined within a method, they may also be defined within an argument to a method.

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

Define Concurrency

A

To be able to perform multiple processes at same time

Each process happens in parallel without having to wait for each other to be scheduled

(including the potential interaction between them)

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

What is multiple tasks at the same time called?

A

Parallelism

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

Why is concurrency important?

A

Most efficient use of hardware - gets the most out of the processor and its cores

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

What is a thread?

A

Can be treated as lightweight processes

Threads exist within a process

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

Why use threads instead of separate programs?

A

Easier to manage multiple threads under a process than have multiple different programs

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

What is Multi-threading

A

OS can run threads in parallel
- Virtually, on a single core processor
- Actually, on a multi-core processor

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

Define Nondeterminism

A

Where the exact order in which processes are executed cannot be predicted

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

What causes Nondeterminism?

A

Multiple tasks are running at the same time, and the OS may decide to swich between them at different moments

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

What is Liveness?

A

In simple terms, it means that the system isn’t stuck, frozen, or waiting forever—it ensures that things keep moving forward, like responding to user actions, processing data, or handling requests

Examples:
- A website showing search results when you hit “search.”
- A background task in an app eventually finishing its job.

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

What are the 2 ways threads can be created in Java?

A
  1. Using the Thread class
  2. Using the Runnable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

How to stop a Thread?

A
  1. Setting a flag
  2. Interrupting
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

What are Race Conditions?

A

When two threads try to access/change data at the same time

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

Define an Atomic Action

A

In programming, atomic actions are self-contained, they can’t be stopped in the middle

  • They either happen or don’t
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What is Deadlock?

A

When thread 1 needs a resource in thread 2, and thread 2 needs a resourse in thread 1

This creates a deadlock and nothing happens as to run they both require resources from each other, creating an infinite cycle - deadlock

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

Define Starvation

A

Where a thread can’t gain regular access to shared resouces because another thread is frequently calling the objects methods

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

Define Livelock

A

Similar to deadlock, except that it occurs when 2 threads are too busy responding to one another to work

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

What does wait() do?

A

Releases the lock and regains it using the notify()

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

What is the difference between Wait and Sleep?

A

Wait
- Must occur in block synchronised on the monitor object
- Releases the monitor (lock) when called; doesn’t sacrifice the remainder of its time slice
- Will wake up if notified via call

Sleep
- Doesn’t need to occur in a synchronized block
- Retains the monitor (lock) when called and sacrifices the remainder of its time slice
- Can only be woken up by an interruption (not by notify)

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

What is a Thread lifecycle?

A

Thread needs to wait to start until the start method is invoked goes between runnable and running, this is dependent on the OS

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

What is Yield()?

A

Identifies the current thread as doing something not particularly important

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

How does Yield() work?

A

Causes the currently executing thread object to pause and allow other threads to execute

If no other threads of the same priority need to execute, the thread continues.

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

What is Join()?

A

Allows one thread to wait for the completion of another

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

How to stop a Join()?

A

Like sleep, responds to an interrupt

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

What is important about the data threads access?

A

Need to ensure the data our threads are accessing is fresh (up to date)

Stale data can lead to large issues

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

What are Atomic Variables?

A

Variables that support atomic operations, ensuring that increments, decrements or reads happen as a single uninterruptible action

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

Explain volatile & data freshness

A

Volatile: : A volatile variable is a variable that can change at any moment, often due to factors outside the program

Data Freshness: How recent or up-to-date the data is, fresh data is reliable and current.

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

What is publishing?

A

Publishing an object is when you make it available outside its current scope

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

By default should you publish an object?

A

By default, we shouldn’t have to publish an object unless we have to
- if we do, we may need to confirm the thread-safe nature of the publishing

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

What is an escaped object?

A

An object published when it should not have been

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

List 4 key points about thread confinement.

A
  1. One of the simplest ways to ensure thread-safety
  2. If the data doesn’t need to be shared, confine it to a single thread
  3. If data is only used by a single thread then its said to be confined
  4. Thread confinement is an element of the programs design
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

What is a Lambda expression?

A

Essentially a block of code that you can pass a round between objects

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

Define Version Control

A

Tracking and managing your files by recording changes over time, you can recall specific versions later

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

How does a Version Control System work?

A

In a team setting if a change is made that isn’t wanted by other members, they can revert the changes back to before

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

What are three key factors of a Version Control System?

A
  • If a new person joins a team they can check the older versions to understand the progress of the project
  • Sharing of files and information about the project
  • Modern version control systems have atomic commits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

What are the advantages of using a Version Control System?

A

Gives a development team a project wide undo button

Place to store all files/documents/directories - repository

Repository acts as a server

Allows multiple developers to work on same code in controlled manner

Keeps record of changes

Can support multiple releases at same time

Time machine can examine how project looked at particular dates/versions

Can see who added/changed code - name/blame

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

Centralized vs Distributed repositories

A

As soon as you commit to a centralized repository others can see your changes

Developers must push changes and pull updates from distributed repositories

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

Copies vs Versions in Version Control Systems

A

Doesn’t just store copies, it stores every version that has ever been checked in

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

What are Revision Tags?

A

Allow you to provide text for particularly important revisions

Easier to remember and more informative than version numbers

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

What is a Trunk?

A

Main code base that developers are working on

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

What is Branching?

A

Like creating a copy of your project to work on separately without affecting the main version. You can make changes, try new features, or fix bugs in the branch, and later merge it back into the main project once everything works well.

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

What is Forking?

A

Forking means creating a personal copy of someone else’s project in your own repository. It’s like copying the whole project to your account so you can work on it independently.

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

What is Merging?

A

Merging back the changes made in branch

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

What is Strict Locking?

A

Only one person can change a file at any one time

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

What is Optimistic Locking?

A

All files can be changed, but if changed in the repository since last check out then local copy needs to be updated before you can commit a change

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

What are the implications of Optimistic Locking?

A

The version control system doesn’t know what you want - so it leaves it up to you to sort out

If you commit a file which has changed since you last updated you will be told the commit has failed

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

What is an Event?

A

Something that happens in a program

(Such as: pressing a key)

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

What is a Listener?

A

A function/piece of code that waits for a specific event to happen, and responds by executing some action.

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

Polling vs Event-Driven Programming.

A

In event-driven programming, instead of repeatedly checking for events, the system waits and responds to an event only when it occurs - typically more efficient

Polling on the other hand is less efficient, because it consumes resources even when nothing happens

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

What are Alternatives to Polling?

A

Interrupts - where the hardware or OS alerts the software when an event occurs
Event Listeners - where the system waits for an event to trigger a specific action

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

Why use Events & Listeners - GUIS?

A
  • Can check for button presses and clicking on graphical icons
  • Efficient use of resources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

What is a source?

A

An object that generates an event

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

What is a key model used in Software Development?

A

V-Model

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

What is the V-Model?

A

Extends the Waterfall Model by emphasizing testing at every stage. Follows a sequential process, where each development phase has a corresponding testing phase.

The V shape illustrates thee relationship between developing on the left and testing on the right of the V.

It ensures early testing and verification, but is rigid, making it less flexible for changes once a phase is complete

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

What is the concept of operations in the V-Model?

A
  • Provides a statement of the goals and objectives of the system
  • Includes strategies, tactics, policies and constraints affecting the system - so contextualizes the system in the wider business
  • Clear statement of responsibilties and authorities to the various participants involved in the system
  • Specifies the processes for iniating, developing, maintaining and retiring the system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

What is the Requirement analysis in the V-Model?

A

Cover three core areas:
1. Requirement gathering
2. Are the gathered requirements, clear, complete, consistent and unambiguous?
3. Clear statement of responsibilities and authorities to the various participants involved in the system

  • Also what can the system achieve with time?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q

What is the High-Level design in the V-Model?

A

Will describe the platforms, systems, products, services, that the developed system will depend on

Typically will include an architecture diagram - this will show the interface, components and networks that need to be further specifed or developed

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

What is the Detailed design in the V-Model?

A

Specifies how the system will be constructed
- for instance how the functions/objects/methods should be

Once detailed design is generated it should be possible to write the tests before the actual system is implemented

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

What is Unit Testing in the V-Model?

A

Testing individual blocks of code in terms of correctness

(Probably the most widely used testing type that you have done so far)

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

What is Integration Testing in the V-Model?

A

Testing the final system when grouped together or integrated
Unexpected behaviour may arise at this point, which is checked for here

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

What is System Testing in the V-Model?

A

Testing the system as a whole
- Also checks that it doesn’t impair performance on the wider environment
- Affecting broader resource availability on the OS
- Affecting other applications working on the same system

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

What is User Acceptance Testing in the V-Model?

A

Plans are developed during requirement analysis phase and are composed by users

Is performed in a user environment that resembles the production environment and uses realistic data

Ensures that the delivered system meets the users requirements and system is ready for use in real time

It’s based on validation rathjer than verification

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

What are the advantages of the V-Model?

A

Highly structured, phases completed one at a time

Works well where all requirements are understood

Simple to understand

Easy to manage - each phase has a definite end with a review

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

What are the disadvantages of the V-Model?

A

Once a project is in the tesing phase it is difficult to go back and change functionality

Not suitable for projects where requirements might change

No working software created until late in the cycle

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

What are the Testing Categories?

A

Static Testing

Dynamic Testing
- White box testing
- Black box testing
- Grey box testing

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

What is Static and Dynamic Testing?

A

Static Testing - accessing documents

Dynamic Testing - testing that involves executing program code

100
Q

What is White box testing?

A

Testing where the internals of the program are known, so can test explicit paths through the system

101
Q

What is Black box testing?

A

Treats code as a “black box”, and therefore is only concerned with functionality

102
Q

What is Grey box testing

A

Know both the required functionality and also some of the implementation concepts which can be used in test design, but not code base exposed

103
Q

What are the advantage/disadvantage of White box testing?

A

Advantage
- Code can be seen so tests can be designed to test many paths through the program

Disadvantage
- Knowledge of the internals will influence the testing - can lead to bias in test design

104
Q

What are the advantage/disadvantage of Black box testing?

A

Advantage
- No knowledge of internals so no bias - more likely to result in tests unexpected by programmer

Disadvantage
- High probability that tests will only test a small number of paths through the program

105
Q

What are Unit Tests?

A

Principles of unit test are to test small specific areas of functionality within a program

106
Q

What is Code Coverage?

A

Attempts to measure how much of your code has been tested
It looks at the code directly, and uses a lot of techniques in unit testing to derive a formal message
Different measures of coverage are often reffered to - some are simply infeasible to completely cover
So often a choice has to be made about how much code can be covered

107
Q

What are the four coverage types?

A

Function/method/subroutine coverage
Statement coverage
Decision coverage
Predicate coverage

108
Q

What is Function coverage?

A

Has each method written, had a test written (and run) on

109
Q

What is Statement coverage?

A

Has each line of code been processed by at least one of your suite of tests

110
Q

What is Decision coverage?

A

Has every desicision edge been traversed in your code (if/else)

111
Q

What is Predicate coverage?

A

Has every condition been tested? (not always the same as decision coverage)

112
Q

What are edge cases?

A

Where a variable takes its maximum or minimum possible value

113
Q

What are corner cases?

A

Situations where multiple edge cases occur together, these are even rarer than edge cases, and can be harder to identify and handle

114
Q

Give two examples of corner cases

A

Combining extreme inputs
- Testing with both min and max values together (e.g., a max sized file with invalid
characters)

Multiple boundary conditions
- Checking how a system behaves when several limits are hit at the same time (e.g., a
nearly full database with a complex query

115
Q

What are the Limits of Testing?

A

It’s not possible to test every single aspect of even a moderately simple system
- no. of possible inputs are too large
- Too many possible paths through the system

Testing cannot assert that the software functions correctly under all conditions, but that it functions incorrectly under specific conditions

116
Q

What does Unit Testing prove?

A

It is often very difficult or impossible to “prove” a piece of code works, we can only satisfy ourselves that we haven’t disproved that it works
- Designing tests with this in mind is critical

117
Q

What is the Importance of Unit Testing?

A
  • Reduces time spent on debugging
  • Helps communicate codes inteded use - illustrates how you expect the code to perform on various inputs and conditions
  • The code shouldn’t drift away from the limits put on them by tests
118
Q

What does Right-BICEP stand for?

A

Right – are the boundary results correct (or “right”)
B – are all the boundary conditions correct?
I – can you check the inverse relationships?
C – can you cross-check the results using some other means?
E – can you force error conditions to occur?
P – are the performance characteristics within bounds?

119
Q

What are 6 properties of good tests?

A
  1. You’ve flexed your right bicep
  2. Automatic
  3. Thorough
  4. Repeatable (should produce same results each time)
  5. Independent (of each other test and of the environment)
  6. Professional (written and maintained to the same standard as the shipped code)
120
Q

How to test your tests?

A
  • Improve the tests while fixing bugs
  • Prove the tests by introducing bugs
121
Q

What are the naming conventions when structuring Unit Tests?

A

If the production code class is called Account and a method is called createAccount; Test should be called testCreateAccount
You may have more than one test method that tests createAccount but they should all begin with test

122
Q

How would you set up a Unit Test?

A

Test code must be written to do a number of things:
1. Set up all conditions needed for testing (create any required objects, allocate any needed resources)
2. Call the method to be tested on the object
3. Verify that the object/class to be tested functions as expected
4. Clear up after itself

123
Q

What is an Assertion?

A

Used to verify that the code being tested behaves as expected. If the assertion fails, the test is considered to have failed, and it usually indicates that there is a bug or issue in the code being tested.

124
Q

How does assertEqual & assertNotEqual work?

A

assertEqual(actual, expected) checks if the actual value equals the expected value.

assertNotEqual(actual, expected) checks that the actual value doesn’t equal the expected value.

125
Q

How does assertTrue and assertFalse work work?

A

assertTrue(condition) checks that the boolean condition is True
assertFalse(condition) checks that the boolean condition is False

126
Q

How does assertNull & assertNotNull work?

A

assertNull(value) checks if the value is null
assertNotNull(value) checks if the value is not null

127
Q

How does assertSame & assertNotSame work?

A

assertSame(expected, actual) checks whether two objects are of the same instance
assertNotSame(expected, actual) checks whether two objects are not of the same instance

128
Q

How does fail work?

A

fail(message) wil fail test immediately if flow of control passes to this statement

129
Q

What are Mock Objects?

A

Cheap placeholder objects that are predictable and allow us to test the method we need to in the current class

130
Q

When should you use a Mock Object?

A

When the real object:
- has non deterministic behaviour (not sure how the object will behave)
- is difficult to set up
- has behaviour that is hard to trigger
- is slow
- has (or is) a user interface
- does not yet exist

131
Q

How should you implement a Mock Object?

A
  1. Use an interface to describe the object
  2. Implement the interface for production code
  3. Implement the interface in a mock object for unit testing
132
Q

What are Test Suites?

A

They allow us to group multiple tests classes to run as a single batch
They also allow us to run a specific subset of unit tests from multiple test classes

133
Q

What are the benefits of Test-driven development?

A

Can help you design your code better
You see the code from the user’s perspective - not the developers

134
Q

What are Invariants?

A

Assertions about classes/objects that should not change - should definitely test these when developing unit tests

135
Q

What are Design Patterns?

A

Meant to provide a general reusable solution to one type of problems during software development

Theory of design patterns is that someone has already solved your similar pattern problems

136
Q

How do Design Patterns relates to OOP design principles?

A

Primarily based on the following principles of OOP design
- Identify the aspects of your application that vary and separate them from what stays
the same
- Program to an interface, not an implementation
- Favour ‘object composition’ over class inheritance

137
Q

What are the 3 types of Design Patterns?

A

Creational Patterns - object creation
Stuctural Patterns - composition of classes and objects
Behavioural Patterns - interaction between objects

138
Q

What is a Factory Pattern?

A

Helps you create objects without specifying their exact class. Think of it as a “factory” that produces items (objects) based on a request, but you don’t need to know how the factory makes them

139
Q

What is an Abstract Factory Pattern?

A

It’s like a factory that creates a set of related products (objects), but you don’t need to know exactly what products are being made. Instead, you just ask for the product, and the abstract factory ensures it’s the right type for your system.

Here’s a simple example:
Imagine you have two types of furniture, Modern and Victorian. For each type, you can have a Chair and a Sofa. Instead of creating each item separately, the Abstract Factory would create a “furniture factory” for each style (Modern and Victorian), and each factory would know how to create the appropriate Chair and Sofa.

140
Q

Factory Pattern vs Abstract Factory Pattern

A
  • Both used for object creation
    • Factory Pattern uses inheritance and gives you a complete object in one shot
    • Abstract Factory Pattern uses composition and returns a family of related classes
141
Q

What is a Builder Pattern?

A

Helps create a complex object by breaking the construction into smaller, manageable steps. It allows you to build an object in a controlled way, step by step, and you can customize the object easily.

142
Q

How does Builder Pattern work?

A
  • The Builder specifies the interface for creating parts of the complex (Product) object.
  • The ConcreteBuilder objects create and assemble the parts that make up the
    Product through the Builder interface.
  • The Director object takes responsibility for the construction process of the complex
    (Product) object, however it delegates the actual creation and assembly to the Builder interface.
  • The Product represents the complex object that is created by the ConcreteBuilder object(s).
  • The Product consists of multiple parts that are created separately by the ConcreteBuilder objects.
143
Q

Factory vs Abstract Factory vs Builder Patterns

A

The main difference is
- Factory pattern construct a complete object in one shot
- Abstract factory pattern returns a family of related classes
- Builder pattern constructs a complex object step by step

144
Q

What are the Benefits of a Builder Pattern?

A
  • Encapsulates the way a complex object is constructed
  • Allows objects to be constructed in a multistep and varying process (as opposed to
    one-step factories)
  • Hides the internal representation of the product from the client
145
Q

What is a Singleton Pattern?

A

Ensures that a class has only one instance, and provides a global point of access to it

146
Q

What are Examples of a Singleton Pattern?

A

Examples
- Windows managers
- File systems
- Print spoolers

147
Q

How to access a Singleton Pattern?

A

Static Member: Create a private static variable of the Singleton class. This is the only instance of Singleton class

Private constructor: Create a private constructor for making sure an outer class can NOT instantiate object from the Singleton class

Static public method: Create a global point of access to get a Singleton instance

148
Q

What is Eager Initialisation?

A

The instance of Singleton class is created at the time of class loading

149
Q

What is Lazy Initialisation?

A

To create the singleton, to ensure that the singleton instance is not created until the getInstance() method is called for the first time

(created only when needed)

150
Q

What is a Thread Safe Singleton?

A

The easier way to create a thread-safe singleton class is to make the global access method synchronized, so that only one thread can execute this method at a time.

151
Q

What is used in an Efficient Thread Safe Singleton?

A

To avoid this extra overhead every time, double checked locking principle is used.

The synchronized block is used inside the if condition with an additional check to ensure that only one instance of singleton class is created.

152
Q

What is a Decorator Pattern?

A

Attaches additional behavioural responsibilities to an object dynamically. Decorators provide a flexible alternative to sub classing for extending functionality

153
Q

What are the principles of a decorator pattern?

A
  • Code should be open for extension but closed for modification
  • Try and design classes that are easy to extend to add new behaviour, but without changing the existing code base
  • Code extension doesn’t only have to come through inheritance in OOP
  • Favour object composition over class inheritance
154
Q

What are some limitations of decorator classes?

A

Takes time and effort
Introduces new levels of abstraction to the object composition

155
Q

List 4 key facts of decorator classes

A
  • You can use one or more decorators to wrap an object
  • Decorators have the same super type as the objects they decorate
  • Objects can be decorated at any time, so we can perform dynamic runtime
    decoration
  • Behaviour comes through the composition of decorators with the base components
156
Q

What does the Command pattern do?

A

Encapsulates a request as an object, thereby letting you parameterise other objects with different requests, queue or log requests, and support undoable operations

157
Q

What does an invoker do in a command pattern?

A

Holds a command and at some point asks the Command to carry out a request by calling its execute() method

158
Q

What does a command do in a command pattern?

A

Is like a “request” or “order” that tells an object (or system) to do something specific

Example:
Think of it like sending a written instruction (the command) to a worker (the receiver) without worrying about how the worker completes the task. You just give the command, and the worker handles the rest.

159
Q

What does a concretecommand do in a command pattern?

A

It takes the request and knows how to perform it by calling the correct method on the appropriate object (called the “receiver”).

Imagine you give a worker a task, like “turn on the light.” The ConcreteCommand is the actual instruction, saying “I want you to turn on this specific light.” It packages the action in a way that the system can execute it.

160
Q

What does a receiver do in a command pattern?

A

Performs the work required to carry out the request. Effectively any class can act as a Receiver

161
Q

What does a client do in a command pattern?

A

Creates and sends commands. The client is responsible for specifying what action needs to be performed, but it doesn’t directly carry out the action itself.

162
Q

What are all the different types of patterns?

A
  1. Factory pattern
  2. Abstact factory pattern
  3. Builder pattern
  4. Singleton pattern
  5. Decorator pattern
  6. Command pattern
163
Q

What design are design patterns primarily based on?

A

OOP design

164
Q

What are OOP design principles?

A
  • Encapsulate what varies
  • Program to an interface, not an implementation
  • Favour “object composition” over class inheritance
  • “open-close principle” - classes should be open for extension but close for
    modification
  • “Dependency inversion principle” - Depend upon abstractions. Do not depend upon
    concrete classes
165
Q

What does Java Generics do?

A

Add stability to code by making more bugs detectable at compile time

166
Q

Why use Java Generics?

A
  • Add stability to code by making types detectable at compile time allowing you to use different types and ensure type safety
  • Allows generic programming for reusable algorithms
  • Use can lead to safer code, as bugs that may appear at runtime, can be deleted at compile time
167
Q

What are the key benefits of Java Generics?

A
  • Avoids casting objects
  • Ensures type-safe collections and methods
168
Q

What are the 3 types of generics?

A
  1. Generic types
  2. Generic methods
  3. Generic constructors
169
Q

In this Non-Generic Example what is the issue?

public class Container {
private Object contents;
public void add(Object contents) {
this.contents = contents;
}
public Object get() {
return contents;
}
}

A
  • Requires careful type casting during retrieval
  • Prone to runtime errors
170
Q

How would you use this Generic Type?

public class Container<T> {
private T contents;
public void add(T contents) {
this.contents = contents;
}
public T get() {
return contents;
}
}</T>

A

Container<Double> container = new Container<>();
container.add(3.7); // Type-safe
Double value = container.get();</Double>

171
Q

What are the Naming Conventions for Generics?

A
  • E: Element (used in collections)
  • K: Key
  • N: Number
  • T: Type
  • V: Value
    Use single, uppercase letters by convention
172
Q

How would you use this generic method?

public class MyClass<T> {
public <a> void genericMethod(A var) {
// Method logic
}
}</a></T>

A

MyClass<Integer> obj = new MyClass<>();
obj.genericMethod("Hello");</Integer>

173
Q

What are Bounded Types?

A

Use bounds for restricting types

Syntax:
- extends: T extends Number
- super: T super Number

174
Q

What is Subtyping?

A

Subtyping allows a type (subtype) to inherit behavior and attributes from another type (supertype). Subtypes can be used in places where supertypes are expected.

Double and Integer are subtypes of Number
?: Known as wilcard

175
Q

What is Type Erasure?

A
  • Compiler removes all generic type information during compilation
  • Generic types are replaced with raw types at runtime
176
Q

What is Heap Pollution?

A

Happens when the type of data stored in the heap memory doesn’t match the type the program expects. This can lead to errors or unexpected behavior.

Example:
Imagine you have a box labeled “Toys,” but someone puts “Books” in it. When you later grab something from the box expecting a toy, you might get a book instead. That confusion is like heap pollution in code.

177
Q

What causes Heap Pollution?

A

Mixing raw and generic types - leads to warnings or runtime errors

178
Q

How would you avoid version mixing?

A
  • Use parameterized types consistently in new code
  • Avoid mixing raw types with generics
179
Q

What is a Collection?

A

An object that groups multiple elements into a single unit

Example:
Poker hand: collection of cards
Mail folder: collection of letters
Telephone directory: mapping names to phone numbers

180
Q

What is a Map?

A

Group of key-value pairs

181
Q

Collection vs Map

A

Collection: A group of objects known as elements

Map: A group of objects where keys map to values

182
Q

Collection Interface purpose and Key Methods ?

A

Purpose: Root interface of most collection classes

Key Methods:
Basic Operations: Add, remove, size, clear, etc.
Bulk Operations: Add all, remove all, retain all.
Array Operations: Convert the collection to an array.

183
Q

Defin a Set Interface

A

Contains no duplicate elements.
Two Sets are considered equal if they have the same elements.

184
Q

What are the 3 set interface concrete implementations?

A

HashSet: Fastest but no guaranteed order
TreeSet: Sorted order, slower than HashSet
LinkedHashSet: Ordered by insertion order

185
Q

Define a List Interface

A

A list is an ordered collection of elements. It may contain duplicate elements

186
Q

What are the 2 list interface concrete implementations?

A

ArrayList: Uses dynamically resizing arrays
LinkedList: Uses doubly linked list.

187
Q

What are the list interface’s key methods?

A

Get/set elements by index
Add/remove elements at specific positions

188
Q

Queue Interface Definition and Key Methods?

A

Definition: Stores elements for processing, typically in FIFO order

Key methods:
- Add/Offer: Insert elements
- Remove/Poll: Retrieve and remove the head of the queue
- Peek: Retrieve the head without removing it

189
Q

Deque Interface Definition and Key Methods?

A

Definition: A Deque (double-ended queue) supports insertion and deletion at both ends.

Key Methods:
- Insert: addFirst(), addLast(), offerFirst(), offerLast()
- Remove: removeFirst(), removeLast(), pollFirst(), pollLast()
- Examine: getFirst(), getLast(), peekFirst(), peekLast()

190
Q

What is a Map Interface?

A

A Map stores key-value pairs, where each key maps to at most one value.

191
Q

Map Interface Key Methods?

A

Key Methods:
- put(K key, V value): Add a key-value pair
- get(Object key): Retrieve the value for a key
- remove(Object key): Remove a key-value pair
- containsKey(Object key): Check if a key exists

192
Q

Map Interface Concrete Implementations?

A
  • HashMap: Fastest, no order guarantees
  • TreeMap: Sorted by keys
  • LinkedHashMap: Maintains insertion order
193
Q

What is a Reflection?

A

Allows a program to inspect and manipulate its structure at runtime (classes, methods, constructors, fields)

194
Q

What is a Reflection’s key uses?

A
  • Examine the class structure at runtime
  • Dynamically invoke methods or access fields
  • Interact with objects that were not known at compile time
195
Q

How would you obtain Class Objects from an instance?

A

Class<?> cls = new Circle().getClass();

196
Q

How would you obtain Class Objects from an class name?

A

Class<?> cls = Class.forName(“java.lang.String”);

197
Q

How would you obtain Class Objects from an .class?

A

Class<?> cls = int.class;

198
Q

Explain how you can obtain Class Objects from an instance, class name and .class

A

Every object has an immutable Class instance, which provides runtime properties and serves as the entry point for reflection.

199
Q

What are Reflection API - Class Instance Field Methods?

A

getFields(): Returns all public fields.
getDeclaredFields(): Returns all fields, regardless of access modifier.

200
Q

What are Reflection API - Class Instance Constructor Methods?

A

getConstructors(): Returns public constructors.
getDeclaredConstructors(): Returns all constructors, including private ones.

201
Q

What are Reflection API - Class Instance Method Methods?

A

getMethods(): Returns all public methods.

Retrieve a specific method:
- Method method = cls.getMethod(“methodName”, ParameterTypes);

202
Q

How would you create Instances using Reflection?

A

Class.newInstance():
- Calls the no-argument constructor.
- Requires the constructor to be visible.

Preferred:
- Constructor<?> constructor = cls.getDeclaredConstructor(ParameterTypes);
Object obj = constructor.newInstance(Arguments);

203
Q

What are Security Considerations with Reflections?

A

Controlled by JVM Manager:
- Public fields/methods are accessible by default
- Private fields/methods need:
- field.setAccessible(true);

Risks:
- Can expose private data
- May create security vulnerabilities in restricted environments

204
Q

What are the Performance and Risks with Reflections?

A

Reflection is slower than direct execution due to runtime resolution.

Risks:
- Breaking abstractions (unexpected side effects).
- Reduced portability across Java versions.
- Harder to optimize reflective code.

205
Q

What are the applications of reflection?

A
  • Testing: Simulate states or enforce conditions.
  • Debugging: Inspect programs and identify errors dynamically.
  • Code Analysis: Inspect class structures for higher test coverage.
206
Q

What are the key takeaways from reflection?

A

Enables dynamic interactions with Java objects.
Use with caution due to security risks and slower performance.
Commonly used in tools like debugging, testing frameworks, and dynamic proxies.

207
Q

Define Networking

A

Communication between computers over a network.
Enables the Internet, mobile apps, and distributed computing.

208
Q

What are the 3 types of Java Networking?

A
  1. TCP (Transmission Control Protocol): Reliable communication.
  2. UDP (User Datagram Protocol): Fast but less reliable communication.
  3. RMI (Remote Method Invocation): Interaction between Java Virtual Machines (JVMs).
209
Q

What is benefits of TCP?

A
  • Reliable, connection-based communication.
  • Guarantees:
    - Data arrives in order.
    - Errors are reported if data order is violated.
  • Used for applications needing data integrity (e.g., HTTP, FTP).
210
Q

What are the benefits of UDP?

A
  • Unreliable, connectionless communication.
  • Features:
    - No guaranteed data order or packet delivery.
    - Lightweight, minimal error-checking.
  • Ideal for live streaming or gaming.
211
Q

What do ports do?

A

Direct data to the correct application on a machine

212
Q

What is an IP address?

A

Identifies the computer on a network

213
Q

What is a Port Number?

A

Identifies the application on a network

214
Q

What is the most common port range?

A

0-1023: Well-known ports (HTTP port 80 etc.)

215
Q

Define a socket

A

Endpoints for communication between two machines

216
Q

How do TCP sockets work?

A

A server listens on a specific IP and port for client connections

Workflow:
- Server binds a socket to a port
- Client connects using the server’s hostname and port
- if accepted, a new socket is created for communication

217
Q

How do UDP sockets work?

A
  • Communication involves sending independent packets (datagrams)
  • No dedicated channel or guarantees for delivery/order
218
Q

How to read/write with sockets using TCP?

A
  1. Open a socket
  2. Create input and output streams
  3. Read/write data based on the server’s protocol
  4. Close the streams and socket
219
Q

How to read/write with sockets with UDP?

A
  • Send data using DatagramPacket
  • Server processes datagrams independently, with no guaranteed sequence
220
Q

TCP vs UDP Key Differences

A

Feature | TCP | UDP
Connection | Connection-based | Connectionless
Reliability | Reliable | Unreliable
Order Guarantee | Maintains data order | No order guarantee
Use Cases | HTTP, FTP | Live streaming, gaming

221
Q

Key information about Networking and sockets in Java?

A
  • Java’s networking API simplifies communication using TCP and UDP.
  • TCP: Reliable, suited for critical data transfer.
  • UDP: Lightweight, faster, less reliable.
  • Choose based on the application’s need for reliability, speed, and data integrity.
222
Q

Define RMI?

A

Allows an object in one JVM (Java Virtual Machine) to invoke methods on an object in another JVM, possibly on a different physical machine.

223
Q

What is the RMI Architecture?

A
  • Server: Creates and registers remote objects.
  • Client: Obtains references to remote objects and invokes methods on them.
224
Q

What are the application of RMI?

A
  • Enables distributed object communication.
  • Supports thin-client architecture by offloading processing to servers.
225
Q

What are the Key Concepts of Distributed Object Applications?

A

Remote Object Location:
- The registry maps remote objects to names.
- References to remote objects are passed for method invocations.

Remote Object Communication:
- RMI handles communication, making it resemble local method calls.

Class Definitions:
- RMI dynamically supports passing class definitions and object contents.

226
Q

What are the Basic Components in Java RMI?

A

Registry:
Maps remote objects to names.
- Methods: bind(), rebind(), lookup().

Server:
Registers remote objects in the registry.

Client:
Looks up remote objects and invokes methods.

227
Q

Define a Remote Interface

A

The interface must extend java.rmi.Remote and its methods must throw RemoteException

Example:
public interface Adder extends Remote {
int add(int a, int b) throws RemoteException;
}

228
Q

What is the Object Interaction in RMI Framework?

A

The process where a program on one computer calls methods or interacts with objects on another computer through RMI

229
Q

What do Policy Files do?

A

Define permissions for downloaded code

Example:
grant codeBase “file:/path/to/classes/*” {
permission java.security.AllPermission;
};

230
Q

How would you run the RMI System?

A

Server Setup:
1. Compile server-side classes.
2. Start RMI Registry (rmiregistry).
3. Launch server application.

Client Setup:
1. Compile client-side classes.
2. Run the client with server details (hostname, port).

231
Q

What are the key advantages of RMI?

A
  • Simplifies distributed computing by abstracting network communication
  • Easily calls methods on remote objects
  • Facilitates scalable and modular system design.
232
Q

What are the key limitations of RMI?

A
  • Tied to Java, limiting cross-platform capabilities.
  • Security configuration requires careful setup.
  • Network latency affects performance.
233
Q

Define Dynamic Code Loading in RMI

A

RMI enables downloading a class definition along with the object reference during remote method invocation

234
Q

What is the purpose of Dynamic Code Loading in RMI?

A

Allows the client to automatically download and use classes from the server at runtime, without needing to have those classes already present on the client machine

235
Q

What is a requirement in order for Dynamic Code Loading in RMI to work?

A

Classes must be downloadable during RMI

236
Q

What is the role of Class Loaders in Java?

A

Every Java class used by the JVM is loaded by a class loader. It manages how classes are loaded into the JVM

237
Q

What are the types of Class Loaders in Java?

A
  1. Bootstrap Class Loader:
    • Loads core Java libraries.
    • Part of the JVM for efficiency.
  2. Extension Class Loader:
    • Loads classes from the system-wide extension directory.
  3. System Class Loader:
    • Loads classes from the current directory or CLASSPATH.
238
Q

What is the order of Precedence of Class Loaders in Java?

A

Bootstrap > Extension > System

239
Q

What are Custom Class Loaders?

A

Can dynamically add classes or search application directories for JAR files.
Example: Subclass java.lang.ClassLoader.

240
Q

Define RMI Architecture

A

Layers:
1. Application Layer: Contains client and server programs
2. Stub & Skeleton Layer: Redirects client calls to remote RMI services
3.Remote Reference Layer: Manages references between client and server objects
4. Transport Layer: Handles communication via TCP/IP
.

241
Q

Whats the difference of Distributed vs Non-Distributed Models?

A

Distributed = Multiple devices sharing the load.
Non-Distributed = One device doing all the work.

242
Q

What is the purpose of downloading Java RMI Stubs?

A

RMI stubs act as client-side proxies for remote objects.
- Forward method invocations to the actual remote object.

243
Q

What are the key advantages of RMI?

A
  1. Dynamic Behavior: Extend JVM behavior dynamically at runtime.
  2. Seamless Remote Communication: Remote method calls behave like local method calls.
  3. Cross-Platform Compatibility: Supports enterprise systems across multiple platforms.
244
Q

What is the summary of Software Development?

A

Software Development Life Cycle:
- Models: Waterfall, Prototyping, RAD, Agile, V-Model, Test-Driven Development.

Core Java Concepts:
- Nested classes, concurrency, event listeners.

Testing Frameworks:
- Unit testing with JUnit or mock objects.

Design Patterns:
- Factory, Singleton, Builder, Decorator.

Advanced Java Features:
- Generics, Collections, Reflection, Sockets, RMI.

245
Q

What is a Stub?

A

Like a proxy on the client-side that makes the call to the remote object

246
Q

What is a Skeleton?

A

Helps on the server-side to receive the call and pass it to the actual remote object

247
Q

What are the 7 stages of the SDLC?

A
  1. Planning
  2. Requirement Analysis
  3. System Design
  4. Implementation
  5. Testing
  6. Deployment
  7. Operation and Maintenance