Lecture 3 Flashcards

1
Q

What are the benefits and drawbacks of (univariate) arrays?

A

Benefits: they are fast to access
Drawbacks: they’re a fixed length, making them waste memory space, difficult to maintain multiple arrays (keeping them synchronised). Needs clean data.

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

What are the drawbacks of (multivariate) arrays?

A

All the values should have the same data type (int or String)

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

When dealing with large data sets, what can a class do?

A

It can be designed to be lightweight, meaning that we shouldn’t implement getters or setters. This is a sensible choice, if we’re dealing with a class whose purpose is to just store data (does not obey encapsulation)
- also it stores the data in the attributes that can be of different types

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

What does the record keyword do?

A

It provides a constructor signature after the record name. it has immutable attributes defined in parentheses after the record name. it provides publicly accessible methods for reading (not setting) their attributes.

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

Give an example of the record keyword.

A

record City(int id, int year, String city) {
//…
}

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

When are records used?

A

Usually for creating immutable data classes.

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

What can a list do?

A

Lists (is a collection) are dynamic, and therefore not of fixed length. It holds elements in a specific order and allows duplicates.
(ArrayList and LinkedList)

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

Give an example of a list.

A

List<CityRecord> allRecords =
new ArrayList<>();</CityRecord>

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

What can a set do?

A

Sets don’t have any order of entry, but ensures that there are no duplicates. You can override the equals() method, if you need the same value multiple times.
(HashSet)

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

What can a map do?

A

Map defines relations from key to value. This allows for easy lookup. The value may be a collection itself (e.g. list) when a key is related to multiple values.
(HashMap)

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

How do you read a txt file?

A

Instantiate the File, instantiate the FileReader, instantiate the BufferedReader. Try to read the line and process it an repeat until there’s nothing left. Then close the file. If there are errors, catch the errors.

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

How do you read a csv file?

A

(Use CSV Parser)
Instantiate the File, then iterate over the CSVRecord and parse it. Then make a for each loop. This is more simple, stable and can solve tricky cases and supports many formats.

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

What does XML mean?

A

Extensible Markup Language. Support built-in for Java

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

What does JSON mean?

A

Java Script Object Notation. Many parsers available, e.g. Google gson

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

True or false: Structured data formats include CSV, XML, JSON and PDF containing natural language.

A

False

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

True or false: An array’s length changes dynamically with the number of elements that are added to it.

A

False

17
Q

True or false: Java offers various collections for storing multiple elements, e.g., List or Map

A

True

18
Q

What does IDE stand for?

A

Integrated Development Environments

19
Q

What IDEs are there?

A

Eclipse:
- Highly configurable
- Easy to extend with own plug-ins
- Open source and free (even for commercial use)

Intellij:
- Fast development
- Includes repository functionality
- Free Community Edition

NetBeans:
- Includes repository functionality
- Extensible with own plug-ins
- Open source and free