Sie sind auf Seite 1von 31

Software Engineering WS 2021/22

Exam (Klausur)
Examiner (Prüfer): Prof. Dr. Thorsten Berger | Date: 03/08/2022

Study program (Studiengang):


Student ID (Matrikelnummer):
Firstname (Vorname):
Lastname (Nachname):
Read the following page before you sign. (Lesen Sie erst die folgende Seite, bevor Sie unterschreiben.)
Signature (Unterschrift):

Graded exam reviewed on (Bewertete Klausur eingesehen am):

Tasks / Aufgaben

1 Software and Software Engineering (5p) 3

2 Java (6p) 4

3 Principles and Paradigms / Prinzipien & Paradigmen (8p) 6

4 UML Class Diagrams / UML Klassendiagramme (13p) 7

5 Processes / Prozesse (5p) 10

6 Requirements Engineering (18p) 11

7 Architecture / Architektur (8p) 16

8 Design Patterns / Entwurfsmuster (8p) 18

9 Testing / Testen (19p) 22

10 Compilers / Compiler (10p) 30

1 / 31
Software Engineering Exam (Klausur)

Instructions

1. All exam pages must be handed in. If pages are missing, the exam is NOT PASSED. You can keep the
separate UML reference guide.
2. No aids other than document-proof pens are allowed. Preferably use blue or black ink. Red ink is not
allowed.
3. The use of any electronic device during the exam will be considered cheating attempt.
4. Cheating attempts include, but are not limited to, talking to other students, using cheat sheets or using
any sheets other than the exam. If your answer does not fit into the space provided, continue writing on
the back and clearly indicate this in the answer field.
5. Extra sheets of paper are available from the proctors.
6. Any loose sheets must contain your name and student ID on the header.
7. By signing this form, you confirm that you have read the information on the exam and that you are ready
and in good health to take the exam.
8. You have 120 minutes to answer the exam. When the time is up, the exam sheet must be handed-in
immediately. There are no negative points.

Good luck!

Hinweise

1. Alle Seiten der Prüfung müssen abgegeben werden. Bei fehlenden Seiten gilt die Prüfung als NICHT
BESTANDEN. Die UML-Referenz können Sie behalten.
2. Andere Hilfsmittel als dokumentenechte Stifte sind nicht erlaubt. Verwenden Sie vorzugsweise blaue
oder schwarze Tinte. Rote Tinte ist nicht erlaubt.
3. Die Verwendung jeglicher elektronischer Geräte während der Prüfung wird als Täuschungsversuch ge-
wertet.
4. Zu den Täuschungsversuchen zählen unter anderem Gespräche mit anderen Studenten, die Verwendung
von Spickzetteln oder die Verwendung von anderen Blättern als die der Prüfung. Wenn Ihre Antwort
nicht in den vorgesehenen Platz passt, schreiben Sie auf der Rückseite weiter und vermerken Sie dies
deutlich im Antwortfeld.
5. Zusätzliches Papier ist bei der Aufsicht erhältlich.
6. Lose Blätter müssen mit Ihrem Namen und Matrikelnummer versehen werden.
7. Mit Ihrer Unterschrift bestätigen Sie, dass Sie die Informationen zur Prüfung gelesen haben und dass Sie
bereit und gesund sind, die Prüfung abzulegen.
8. Sie haben 120 Minuten Zeit, um die Prüfung zu beantworten. Wenn die Zeit abgelaufen ist, muss das
Prüfungsblatt sofort abgegeben werden. Es gibt keine Minuspunkte.

Viel Erfolg!

2 / 31
Software Engineering Exam (Klausur)

1 Software and Software Engineering (5p)

What is software? Provide a definition. (2p)


Was ist Software? Geben Sie eine Definition an.
Answer: 0p: Sinn verfehlt -> unzureichende Lösung
1p: zum Teil richtig
2p: zum größten Teil richtig

Provide an example of a catastrophe caused by a software failure. What was the reason? (2p)
Nennen Sie ein Beispiel einer durch einen Softwarefehler ausgelösten Katastrophe. Was war der Grund?
Answer: 1p für genannte Katastrophe
1p für genannten Grund

What is not an example of a software system? (1p)


Was ist kein Beispiel für ein Softwaresystem?
Answer: 1p für genau ein Kreuz bei Microsoft Word
sonst 0p

# modern car / modernes Auto


# Microsoft Word
# graphical calculator / graphischer Taschenrechner
# none of the above / keins davon

3 / 31
Software Engineering Exam (Klausur)

2 Java (6p)

The following code has some errors, each of which causing a compilation error. Identify them, also give the
line number. (6p)
Der folgende Code hat Fehler, die zu Kompilierfehlern führen. Identifizieren Sie diese, geben Sie auch die
Zeilennumer an.
1 import java.util.List;
2

3 class Error {
4 public static List<Character replicate(Integer size, Character c) {
5 List<Character> res = new List<Character>();
6 for (int i = 0; i < size; ++i)
7 res.add(c)
8 }
9 }

Answer: F ehler:
• the character > is missing behind List <Character
• List is an interface and cannot be instantiated
• semicolon missing after res.add (c)
• return statement missing
für jeden richtigen vollstaendigen Fehler (Zeile und Identifikation): 1,5p - wenn Identifikation fehlt: 0p - wenn
Zeile fehlt: 0,5p fuer jeden falschen Fehler: -0.5p

4 / 31
Software Engineering Exam (Klausur)

5 / 31
Software Engineering Exam (Klausur)

3 Principles and Paradigms / Prinzipien & Paradigmen (8p)

Briefly explain the idea behind generic software engineering (a.k.a., generic programming). (4p)
Erläutern Sie kurz die Idee hinter Generic Software Engineering (auch bekannt als Generic Programming).
Answer: - 2p für sinngemäß wiedergeben: man kann types weglassen; dann noch drei Informationen aus den
entsprechenden Folien (also Kerngedanken treffen + Idee der Allgemeinheit ansprechen) - 2p für einen weiteren
Aspekt oder Beispiel über Generic Progr., der in den Folien erläutert wurde, z.B. ein wichtiger Vorteil (der aus
der Allgemeinheit von Generics folgt)

Does Java support this paradigm? (1p)


Unterstützt Java dieses Paradigma?
Answer: 1p für Antwort ”Yes”

# Yes
# No

What other paradigm(s) does Java support? (3p)


Welche(s) andere(n) Paradigma/Paradigmen unterstützt Java noch?
Answer:
• OO, functional, imperative, structured (earlier versions of Java with goto)
1p pro richtigem Paradigma

6 / 31
Software Engineering Exam (Klausur)

4 UML Class Diagrams / UML Klassendiagramme (13p)

What is the Diamond Problem? (3p)


Was ist das Diamond Problem?
Answer: 1p: Nennung von Mehrfachvererbung
1p: konkrete Struktur der Mehrfachvererbung die zum Diamond-Problem resultiert
1p: Konsequenzen bzw. was ist daran das Problem?

Draw a class diagram that represents the following source code. (10p)
Erstellen Sie ein Klassendiagram, welches den folgenden Quellcode repräsentiert.
Use the following elements when applicable: Benutzen Sie die folgenden Elemente entsprechend (ohne deutsche
Übersetzung, diese Begriffe müssen Sie auf Englisch kennen):
• classes, abstract classes, interfaces
• attributes and methods with their types (including parameters)
• associations, compositions and aggregations with role names (where applicable) and cardinalities/multi-
plicities on both sides
• inheritance and interface realizations
You do not need to use any additional notations, e.g., for visibility. Weitere Notationen wie z.B. Visibility, sind
nicht nötig.
public class Color {
public String name;
}

public interface Car {


double getMaxSpeed();
Color getColor();
}

public interface Team {


public String getName();
}

public class RaceCar implements Car {


private Color color;
private double vmax;
public void tuneUp(double v) {
vmax += v;

7 / 31
Software Engineering Exam (Klausur)

}
public double getMaxSpeed() { return vmax; }
public Color getColor() { return color; }
}

public class SoftRacer extends RaceCar {


protected String name;
public String getName() { return name; }
}

public class HillRacer extends RaceCar {


private double climbAngle;
public double getClimbAngle() { return climbAngle; }
}

public class RaceTeam implements Team {


private String name;
public HillRacer[] hillRacer;
public SoftRacer[] softRacer;
public RaceCar[] getRacecars() {
return ObjectArrays.concat( hillRacer, softRacer, RaceCar.class);
}
public String getName() { return name; }
}

public class Race {


private String location;
private SoftRacer safetyCar;
private RaceTeam[] raceTeams;
public void setTeams( RaceTeam[] teams ){
if( teams == null || teams.length < 2 )
throw new IllegalArgumentException( "Need at least two!");
}
}

8 / 31
Software Engineering Exam (Klausur)

Class Diagram (Klassendiagramm):

9 / 31
Software Engineering Exam (Klausur)

5 Processes / Prozesse (5p)

Consider the following description of a company called Bionsoft.


“Bionsoft is a leading software engineering company in the medical domain. Usually, they meet their clients
only once to define the requirements for a product. Thereafter, they need up to 36 months to implement and test
the solution. In their last projects, they faced serious issues with the integration, since the runtime environment
changed substantially during development. Now, they are about to start a new project, where not only the
environment will change, but also the requirements because of a highly dynamic situation.”
In the course, we classified software engineering processes into two coarse categories. Identify this category
for Bionsoft. Briefly justify your decision. (3p)
In der Vorlesung haben wir Prozesse in zwei grobe Kategorien eingeteilt. Identifizieren Sie diese Kategorie für
Bionsoft. Begründen Sie Ihre Entscheidung.
Answer: 1p für Nennung der Kategorie (plan-based)
2p für Begründung

Propose a process model (and category) that is better suited for Bionsoft’s new project. It is enough to give the
names. (2p)
Schlagen Sie ein besser geeignetes Prozessmodell (und Kategorie) für Bionsofts neues Projekt vor. Es reicht die
Namen zu nennen.
Answer:
• Kategorie: agile; Prozessmodell: ein in der Vorlesung genanntes agiles Modell, aber wir lassen auch nicht
genannte zu wenn definitiv agile
1,5p für Prozessmodel
0,5p für Kategorie

10 / 31
Software Engineering Exam (Klausur)

6 Requirements Engineering (18p)

Übersetzungen dieser Aufgaben sind auf Seite 15.


State Machine Diagram
Draw a state machine diagram that represents the following software updater. You can use the numbers to
represent state names. (6p)
The software updater can be in four states as follows:

1. Display the software update window


2. Search for software updates
3. Display software updates found
4. Install software updates

The updater starts by displaying the software update window. While displaying this window, the user can press
a Search button to start searching for updates. Alternatively the user can press the Close button, to end the
updater. While the updater is searching for updates, the user may abort the search at any time. If the user aborts
the search, the software update window is shown again. When the updater has completed its search, it display
the updates found. The user can press a button Install, then the updater installs the updates. Alternatively,
she can close the updater by pressing a button Finish. The update process cannot be aborted. After finishing
the updates, the updater returns to the start window.

State machine:

11 / 31
Software Engineering Exam (Klausur)

Activity Diagram
Describe the following recipe with an activity diagram. Use very short activity names, it is enough when we
can uniquely map the names to the described activities. (6p)
“Peel 5 potatoes and then cook them. Cut 800g turkey into small stripes. Mix 400ml cream with 20ml lemon
juice. Mix the sauce with cornstarch. If no starch is available, use flour. Cut 60g spring onions. Wash 20g
rosemary and 20 leafs basil, whilst searing the spring onions. Sear the meat, then add the sauce and fry the meat
with the sauce. Add rosemary and basil. Thereafter, add the spring onions. Finally arrange the potatoes and the
meat and serve the meal.”

Activity diagram:

12 / 31
Software Engineering Exam (Klausur)

User Stories (6p)


Extract three user stories (but not whole user story cards) for the new monitoring system from the production
manager’s narrative.
“We are a medium-sized company and produce special nails for different applications. There are almost fifty
machines in our production hall. The new system is to record the status of the machines. The technicians should
be able to call up the relevant data for all machines on their tablets. They will then be able to replace broken
parts more quickly. In the future, predictive maintenance would be nice, of course. The machines are already
all equipped with control boards that can provide this data via WLAN. The data includes, for example, whether
the machine is running and how high its current throughput is. The data should also be stored for later analysis,
so that our employees can see how much a machine has produced over the year. It would be nice if we could see
the status of all the machines in the entrance area at a glance. Then our shift supervisor can see how much we
are currently producing and if there are any problems. Ideally, errors could lead directly to an acoustic warning
signal.”
Answer: je 2p pro Story
Aufteilung der 2p:
- 1,5p Struktur der Story (As [...] i want to [...], ...)
- 0,5p Vernünftiger Inhalt

13 / 31
Software Engineering Exam (Klausur)

1:

2:

3:

14 / 31
Software Engineering Exam (Klausur)

Deutsche Übersetzungen

State Machine Diagram / Zustandsdiagram


Erstellen Sie ein UML-Zustandsdiagram nach der folgenden Beschreibung. Sie können die Zustandsnummern
als Namen der Zustände verwenden.
Der Software-Updater kann die folgenden vier Zustände annehmen:

1. Anzeigen des Software-Aktualisierungsfensters.


2. Suche nach Software-Updates
3. Anzeige der gefundenen Software-Updates
4. Softwareaktualisierungen installieren

Der Updater beginnt mit der Anzeige des Software-Update-Fensters. Während dieses Fenster angezeigt wird,
kann der Benutzer eine Schaltfläche Search drücken, um die Suche nach Updates zu starten. Alternativ kann
der Benutzer die Schaltfläche Close drücken, um den Updater zu beenden. Während der Updater nach Ak-
tualisierungen sucht, kann der Benutzer die Suche jederzeit abbrechen. Wenn der Benutzer die Suche abbricht,
wird wieder das Software-Aktualisierungsfenster vom Anfang angezeigt. Wenn der Updater seine Suche abge-
schlossen hat, zeigt er die gefundenen Aktualisierungen an. Der Benutzer kann auf eine Schaltfläche Install
drücken, dann installiert der Updater die Updates. Alternativ kann er den Updater durch Drücken einer Schalt-
fläche Finish schließen. Der Aktualisierungsvorgang kann nicht abgebrochen werden. Nach Abschluss der
Aktualisierungen kehrt der Updater zum Software-Aktualisierungsfenster vom Anfang zurück.
Activity Diagram / Aktivitätsdiagramm
Beschreiben Sie das folgende Rezept mit einem Aktivitätsdiagramm. Benutzen Sie kurze Aktivitätsbeschrei-
bungen, es reicht wenn sie eindeutig den Tätigkeiten zugeordnet werden können.
“Schäle 5 Kartoffeln und koche sie anschließend. 800g Pute in kleine Streifen schneiden. 400ml Sahne mit
20ml Zitronensaft verrühren. Die Soße mit Speisestärke anrühren. Wenn keine Stärke vorhanden ist, Mehl
verwenden. 60 g Frühlingszwiebeln schneiden. Die Frühlingszwiebeln anbraten und währenddessen 20 g Ros-
marin und 20 Blätter Basilikum waschen. Das Fleisch anbraten, dann die Soße dazugeben und das Fleisch mit
der Soße anbraten. Rosmarin und Basilikum dazugeben. Anschließend die Frühlingszwiebeln dazugeben. Zum
Schluss die Kartoffeln und das Fleisch anrichten und das Gericht servieren.”
User Stories
Gewinnen Sie aus der Erzählung des Produktionsleiters drei User Stories (aber keine vollständigen User Story
Cards) für das neue Überwachungssystem:
“Wir sind ein mittelständisches Unternehmen und stellen Spezialnägel für unterschiedliche Anwendungsfälle
her. In unserer Produktionshalle befinden sich knapp fünfzig Maschinen. Mit dem neuen System soll der Status
der Maschinen erfasst werden. Die Techniker sollen auf ihren Tablets zu allen Maschinen die relevanten Da-
ten abrufen können. Dann können sie schneller kaputte Teile tauschen. Zukünftig wäre predictive maintenance
natürlich schön. Die Maschinen sind bereits alle mit Steuerboards ausgestattet, die diese Daten via WLAN
bereitstellen können. Zu den Daten gehört beispielsweise ob die Maschine läuft und wie hoch ihr momentaner
Durchsatz ist. Die Daten sollen zur späteren Analyse auch gespeichert werden, sodass unsere Mitarbeiter nach-
vollziehen können, wie viel eine Maschine über das Jahr produziert hat. Es wäre schön wenn wir den Status
aller Maschinen im Eingangsbereich auf einen Blick erfassen könnten. Dann kann unser Schichtführer sehen
wie viel wir momentan produzieren und ob es Probleme gibt. Fehler könnten idealerweise direkt zu einem
akustischen Warnsignal führen.”

15 / 31
Software Engineering Exam (Klausur)

7 Architecture / Architektur (8p)

What is the difference between layered architectures and tiers? (2p)


Was ist der Unterschied zwischen Layered Architecture und Tiers? Answer: Check answer 2 (2p)
# the realization of information hiding / wie Information Hiding realisiert wird
# the cardinalities/multiplicities of relationships between layers/tiers / die Kardinalitäten/Multiplizitäten
der Beziehungen zwischen layers/tiers
# One prescribes a certain kind of interfaces / eins davon schreibt eine bestimmte Art Interfaces vor

What is the difference between a framework and a library? (4p)


Was ist der unterschied zwischen einem Framework und einer Bibliothek?
Answer:
• 2p: brief description of what library is; brief description of what framework is
• 2p: discussion of what the library controls vs. what the framework controls (program structure and control
flow)

Example:
What are the namesHeartbeat + Redundancy
of the two architectural tactics realized in the following engine control architecture? (2p)
Wie heißen die beiden architectural tactics, die in der folgenden Motorkontrollsteuerungs-Architektur verwen-
Example: engine control
det wurden?
Monitor and Selection in addition have a simple engine control capability

engine control

Monitor
Reset Failure-
Mode
Heartbeat

Complex
Control
Actors
Selection
Sensors Simple
Control

Prof. Dr. Thorsten Berger | Software Engineering | Lecture 8: Architecture Implementation

16 / 31
Software Engineering Exam (Klausur)

Answer:
• Heartbeat (1p)
• if wrong, then 0.5p for: Availability, Fault Detection (0.5p)
• Redundancy (1p)
• if wrong, then 0.5p for Fault Recovery

17 / 31
Software Engineering Exam (Klausur)

8 Design Patterns / Entwurfsmuster (8p)

Übersetzungen auf Seite 21.


Database Application
You develop an application that reads from and writes to databases. You decide to modularize your database
accesses using two different classes: a database reading and a database writing class. As you want to support
multiple database types (e.g., MySQL, MongoDB), you implement database specific readers and writers for
each supported database. To ensure the program works as intended, you need to ensure at runtime that you
create and use only compatible database readers and writers (e.g., a MySQLReader should only be used together
with a MySQLWriter).
How would you solve this issue? Propose a design pattern and explain how it solves the problem. Include into
your explanation, which classes the pattern provides and which concepts in the concrete example correspond
to which pattern classes. (4p)
Answer: + 1 Punkt für die Nennung des richtigen Patterns
+ 1,5 Punkte für die richtige Erklärung des Patterns
+ 1,5 Punkte für die richtige Begründung der Patternwahl

18 / 31
Software Engineering Exam (Klausur)

19 / 31
Software Engineering Exam (Klausur)

Temperature Monitoring
The temperature in a coldroom needs to be at a specific value to ensure the stored food remains safe for eating.
As even small changes in temperature can lead to huge problems, a restaurant wants its staff to be notified
automatically when the temperature changes according to the coldroom’s sensors.
How would you solve this issue programmatically? Propose a design pattern and explain how it solves the issue.
Include into your explanation, which classes the pattern provides and which concepts in the concrete example
correspond to which pattern classes. (4p)
Answer: + 1 Punkt für die Nennung des richtigen Patterns
+ 1,5 Punkte für die richtige Erklärung des Patterns
+ 1,5 Punkte für die richtige Begründung der Patternwahl

20 / 31
Software Engineering Exam (Klausur)

Deutsche Übersetzungen

Database Application / Datenbank-Applikation


Sie entwickeln ein Programm, das Daten aus Datenbanken ausliest und wieder in Datenbanken schreibt. Sie
haben sich entschieden ihre Datenbankzugriffe mit zwei verschiedenen Klassen zu modularisieren: eine Klas-
se zum Lesen und eine Klasse zum Schreiben. Da Ihr Programm verschiedene Datenbanktypen unterstützen
soll (z.B. MySQL, MongoDB), implementieren Sie datenbankspezifische Lese- und Schreibeklassen für jede
unterstützte Datenbank. Um sicherzustellen, dass das Programm sich wie gewünscht verhält, müssen Sie si-
cherstellen, dass während der Laufzeit nur kompatible Lese- und Schreibeklassen instanziiert und verwendet
werden (z.B. darf ein MySQLReader nur mit einem MySQLWriter verwendet werden).
Wie lösen Sie dieses Problem? Schlagen Sie ein Entwurfsmuster vor und erklären Sie, wie es das gegebene
Problem löst. Nehmen Sie dabei auch Bezug auf die Klassen, die das Entwurfsmuster bereitstellt und welche
Konzepte aus der oberen Erklärung sich welchen dieser Klassen zuordnen lassen.
Temperature Monitoring / Temperaturüberwachung
Die Temperatur eines Kühlraums muss einen bestimmten Wert halten, um sicherzustellen, dass das darin aufbe-
wahrte Essen nicht verdirbt. Da bereits kleine Temperaturschwankungen zu großen Problemen führen können,
sollen die Angestellten eines Restaurants jederzeit benachrichtigt werden, wenn die Temperatursensoren des
Kühlraums eine Änderung feststellen.
Wie lösen Sie dieses Problem programmatisch lösen? Schlagen Sie ein Entwurfsmuster vor und erklären Sie,
wie es das gegebene Problem löst. Nehmen Sie dabei auch Bezug auf die Klassen, die das Entwurfsmuster
bereitstellt und welche Konzepte aus der oberen Erklärung sich welchen dieser Klassen zuordnen lassen.

21 / 31
Software Engineering Exam (Klausur)

9 Testing / Testen (19p)

Is the following testcase a positive or a negative testcase? Why? (Hint: The function Math.floorDiv(x,y)
returns the largest integer, that is smaller than or equal to the result of x/y.) (2p)
Handelt es sich im folgenden um einen positiven oder einen negativen Testfall? Warum? (Tipp: Die Funktion
Math.floorDiv(x,y) gibt den größten Integer-Wert zurück, der kleiner gleich x/y ist.)

@Test
public void test(){
int dividend = 2;
int divisor = 0;

assertThrows(
ArithmeticException.class, ()-> Math.floorDiv(dividend, divisor)
);
}

Answer: 1 Pkt für negativen Testcase


1 Pkt für korrekte Begründung Lösung: Negative Testcase, because it checks if there is a zero-Division Excep-
tion(negative case for Division)

Where is the test oracle in the above provided source code? Name three different ways to obtain test oracles in
general. (4p)
Machen Sie das Testorakel im obigen Quellcode kenntlich. Nennen Sie drei verschiedene Möglichkeiten zur
Erstellung von Testorakeln im Allgemeinen. Answer: 1 Pkt pro korrekten Weg
1 Pkt für korrekte Position im Quellcode
Lösung: Test Oracle: assertThrows(ArithmeticException.class, () -> Math.floorDiv(dividend, divisor))
1) Derived (Previous Version, other Programm, ...)
2) Implicit (crash, Exception, ...)
3) Specified (Human, model, ...)
or Also:
1) Property Bases Testing
2) Differential Testing
3) Regression Testing

22 / 31
Software Engineering Exam (Klausur)

23 / 31
Software Engineering Exam (Klausur)

Consider the following code excerpt. Betrachten Sie folgendes Stück Code.

1 public static int number (int x, int y) {


2 if (x == y) {
3 return x;
}

4 int i;
5 int j = 1;
6 int n = 0;

7 if (x > y) {
8 i = y;
9 j += x;
10 } else {
11 i = x;
12 j += y;
}

13 do {
14 n += i;
15 ++i;
16 } while (i < j);

17 return n;
}

What does the method number calculate? (4p)


Was berechnet die Methode number? Answer: Summe von i von min(x,y) bis max(x,y).
2 Pkt für Idee in richtige Richtung
3 Pkt, wenn die Grenzen nur leicht falsch sind
4 Pkt, wenn komplett richtig Lösung:
max(x,y)
X
i
i=min(x,y)

24 / 31
Software Engineering Exam (Klausur)

Create the control-flow diagram for the given code. Use the given line numbers as labels (combine, like in the
lecture, lines for blocks, e.g., 4–6). Ignore all curly braces, start in line 1. (4p)
Erstellen Sie das Kntrollfluss-Diagramm für diesen Code. Nutzen Sie die gegebenen Zeilennummern als Be-
zeichner (kombinieren Sie, wie in der Vorlesung, Zeilen für Blöcke, z.B. 4–6). Ignorieren Sie alle geschweiften
Klammern und beginnen Sie in Zeile 1. Answer: 1 Pkt 1. If korrekt
1 Pkt if-else korrekt
1 Pkt While-Schleife enthalten
1 Pkt diagramm komplett korrekt (oder zur freien Verfügung)

25 / 31
Software Engineering Exam (Klausur)

Lösung:

26 / 31
Software Engineering Exam (Klausur)

27 / 31
Software Engineering Exam (Klausur)

What is the minimum number of different test cases needed to achieve 100% statement coverage? (1p)
Was ist die minimale Anzahl an unterschiedlichen Testfällen, um 100% statement coverage (Anweisungsabde-
ckung) zu erzielen? Answer: 1 Pkt für Antwort 3

What is the minimum number of different test cases needed to achieve 100% branch coverage? (1p)
Was ist die minimale Anzahl an unterschiedlichen Testfällen, um 100% branch coverage (Verzweigungsabde-
ckung) zu erzielen? Answer: 1 Pkt für Antwort 3

Implement test cases to achieve 100% statement & branch coverage. Use Algo.number(param, param)
to call the method. (3p)
Implementieren Sie geeignete Testfälle um 100% statement & branch coverage zu erzielen. Benutzen Sie Algo
.number(param, param) um die Methode aufzurufen.

@Test
public void firstTest(){

28 / 31
Software Engineering Exam (Klausur)

1 Pkt pro korrektem Testcase (nur, wenn nicht Duplikat, Testcase muss mehr Infos zur Coverage hinzufügen)
Lösung:
1 public void firstTest(){
2 final int x = 2;
3 final int y = 2;
4 final int z = Algi.number(x,y);
5 Assertion.assert.Equals(x,z)

1 public void secondTest(){


2 final int x = 5;
3 final int y = 2;
4 final int z = Algi.number(x,y);
5 Assertion.assert.Equals(14,z)

1 public void thirdTest(){


2 final int x = 2;
3 final int y = 5;
4 final int z = Algi.number(x,y);
5 Assertion.assert.Equals(14,z)

29 / 31
Software Engineering Exam (Klausur)

10 Compilers / Compiler (10p)

The following regular expression defines a language of identifiers built from small letters and underscores.
Der folgende reguläre Ausdruck definiert eine Sprache von Identifiers, aufgebaut aus kleinen Buchstaben und
Unterstrichen.
(“_”|[“a”-“z”])*
Propose an improvement to this regular expression so that an identifier can no longer be built solely of unders-
cores (so if it starts with underscore it has to contain some letters, and possibly more underscores mixed in).
(5p)
Schlagen Sie eine Verbesserung dieses Ausdrucks vor, sodass ein Identifier nicht mehr nur aus Unterstrichen
bestehen kann (also wenn er mit Unterstrichen beginnt, muss er einige Buchstaben und mglw. weitere Unter-
striche reingemischt enthalten).

Answer:
(’_’+[’a’-’z’]+)|[’a’-’z’]+) (’_’|[’a’-’z’])*
or
(’_’* [’a’-’z’]+) (’_’|[’a’-’z’])*
or
(’_’|[’a’-’z’])* [’a’-’z’] (’_’|[’a’-’z’])*

5p for completely correct solution; 3.5p if small problems (e.g., if identifier cannot
start with letter); 2p if the idea goes into the right direction
Consider the following context-free grammar. In this grammar, S is the start symbol, capital letters represent
non-terminals, and small letters are terminal symbols. The Greek letter ϵ represents an empty string (no charac-
ters).
Betrachten Sie folgende kontextfreie Grammatik. S ist das Startsymbol, große Buchstaben sind Nichtterminal-
Symbole, und kleine Buchstaben sind Terminal-Symbole. Der griechische Buchstabe ϵ repräsentiert einen leeren
String (keine Zeichen).

S →ABC
A → Aa | ϵ
B → Bb | ϵ
C → Cc | ϵ

Write a regular expression that accepts the same language. (5p)

30 / 31
Software Engineering Exam (Klausur)

Erstellen Sie einen regulären Ausdruck, der dieselbe Sprache akzeptiert.


Answer:
a*b*c*

5p for completely correct solution


3.5p if small problems
2p if the idea goes into the right direction

Answer: a *b*c*
5p for a completely correct answer; 1p for a+b+c+; 0p for a wrong answer

31 / 31

Das könnte Ihnen auch gefallen