Vigtige ting Flashcards
Make a unit test like in the lecture (calculator)
public class CalculatorTest{ @BeforeEach public void setup(){ Calculator c = new Calculator(); } @Test public void mulTest(){ private int result = c.mul(2, 2); assertEquals(4, result); } }
Write the skeleton for an if-statement:
boolean condition = true if (condition) { // something happens } else { // something ELSE happens }
Write the skeleton for a while-statement:
while (condition) { //something happens }
Write the skeleton for a for loop-statement:
for (int i = 0; i < 0; i++) { //do something 10 times }
Write the skeleton for a for each-statement:
String[] mylist = {"Red", "Green", "Blue"} for (String content : mylist) { // do something }
Can you use “==” on Strings?
No, you instead usemessage.equals("Hello, World");
Create an instance of a class:
Super class is Car, subclass is ElectricCar:Car myCar = new ElectricCar();
how to write main?
public class Main{ public static void main(String[] args) { System.out.println("Execute program"); }
What are the benefits of OOP?
Abstraction, encapsulation, inheritance and polymorphism (maybe modularity?)
What is polymorphism?
When there are one or more classes or objects related to each other by inheritance. They behave the same. One of the benefits of polymorphism.
How do you use super
?
Attributes: super(name, age);
Methods: super.animalSound();
Write a getter and a setter:
public int getPrice(){ return price; } public setPrice(int price){ this.price = price; }
How to make enumeration in code?
enum level { LOW, MEDIUM, HIGH }
Make an abstract class with an abstract method in it:
public abstract class Animal{ private int age; public abstract move(); }
Make a constructor:
public class Animal{ private int age; private String name; public Animal(int age, String name){ this.age = age; this.name = name; } }
What is static type and dynamic type?
Static type is known during DEVELOPMENTPet somePet = new Pet();
PET IS STATIC
Dynamic type is known during EXECUTIONPet somePet = new Dog();
DOG IS DYNAMIC
What does instanceof
do?
Checks whether object is an instance of the specified type
if (Pet instanceof Dog) { //does something }
What is method overriding and method overloading?
Method overriding: Changes the method implementation of the super class. Keeps the same method signature (name and parameters).
Method overloading: Provides additional implementation, and changes the method signature, by having different parameters
(drive(Direction direction)
and drive(Location location)
, the latter is the new implementation)
What are arrays and lists?
Arrays are for fixed numbers, allows speed of access.
Lists are dynamic and allows for ease of access
What does abstraction mean?
Focusing on details (necessities), leaving out unnecessary details.
What is encapsulation?
Regulates access to members from the outside. Put them in a capsule to protect them. Use visbility modifiers for this.
What does inheritance mean?
Reusing code (rather tha duplicate) and inherits from the super class (kind of polymorphism, because behaviours and traits are shared)
What is an interface?
Specifies some methods that all classes that implements the interface, should implement. All interfaces methods are abstract and public, attributes are public, static and final.
How to write an interface and implement it in a class?
interface Animal { public void makesound(); public void eat(); } public class Pig implements Animal interface { // implement methods now }
What is software development?
ITERATIVE AND INCREMENTAL
Give an example of a list:
List allRecords = new Arraylist<>();
OR
List<Elements> content;
Benefits of IDEs
Highlighting, debugging, code completion, execution
What terms are used when defining a Version Control Syste (VCS)?
Version, development line, branch, merge, tag, merge conflict
What is SVN (Subversion)?
Client-server VCS, local working copy and remote repository.
~~~
svn import
svn checkout
svn commit
svn update
~~~
import: from working copy to remote repository
checkout: from remote repository to working copy
commit: from working copy to remote repository
update: from remote repository to working copy
Characteristics of SVN:
Checks out only PARTS of the project
Renames counts as a totally new file
Not that great for non-linear workflow
What is Git?
Distributed VCS, working copy, local repository and remote repository
git init git clone (git add) git commit git push git pull
init: initialises from the working copy to the local repository
clone: clones from the remote repository to local repository and then working copy
commit: commits from working copy to local repository
push: pushes changes from local repository to remote repository
pull: pulls from remote repository to local repository and then working copy
How many releases are there?
Long term support: old versions, too costly to implement new version for whole firm
Stable: the current version, most people use this
Pre-release: beta, alpha, contains newest features (not tested properly)
What is Hadoop and Spark?
Both are tools used in parallel data processing.
- Hadoop uses HDFS (Hadoop distributed file system), HiveQL
- Spark uses RAM (therefore more expensive) SparkSQL
Name the data storage tools
Apache HBase
Apache Phoenix
Druid
Cassandra
Name the data calculation tools
Apache Pig
Apache Kafka
Apache Samza
Name the data query tools
Apache Hive
Apache Drill
Name the coordination tools
Apache Zookeeper