Final Exam Review Flashcards

1
Q

Why Java?

A
  1. well documented and standardised across platforms
  2. OOP concepts have simple and easy to understand behaviour
  3. great libraries for handling basic collections
  4. easy to manage multiple threads
  5. garbage collector (no delete)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Java references

A

all object variables, refer to data in memory (pointers in C++)

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

Classes consist of…

A

member variables, constructors, methods

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

What is an object?

A

an instance of some class

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

extends

A

Java keyword to express one class is a child of another class (inherits member variables and methods)

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

method overriding

A

if a child class has identical method signature as parent class, child class method overrides parent class method

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

super

A

keyword used to access resources from parent class

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

structure of a method signature

A

access-modifier return-type name input-arguments

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

protected (access modifier)

A

can be accessed internally and within child classes

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

polymorphism

A

when parent class reference refer to a child class object

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

method overloading

A

two methods have same name but different signatures so no conflicts occurr

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

what does an interface and a class that implements that interface look like?

A

// Interface
interface Animal {
public void animalSound(); // interface method (does not have a body)
public void sleep(); // interface method (does not have a body)
}

// Pig “implements” Animal interface
class Pig implements Animal {
public void animalSound() {
// The body of animalSound() is provided here
System.out.println(“The pig says: wee wee”);
}
public void sleep() {
// The body of sleep() is provided here
System.out.println(“Zzz”);
}
}

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

abstract class

A

partially specified class that cannot be instantiated (but can be extended by a child class)

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

abstract method

A

method that is declared without implementation

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

what are the differences between an abstract class and an interface?

A
  • polymorphism works with both
  • a class can implement multiple interfaces but can extend one abstract class
  • abstract classes can include some implemented methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

primitive data vs objects

A

primitive data types are predefined and stored in the stack
objects are created by users (value stored in stack, the real variable in heap)

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

process

A

ongoing execution of a computer program (don’t share resources with each other)

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

thread

A

a means to split execution into multiple simultaneous executions

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

code multithread in Java

A

// Make a subclass of thread
class MultithreadingDemo extends Thread {
public void run()
{
try {
// Displaying the thread that is running
System.out.println(
“Thread “ + Thread.currentThread().getId()
+ “ is running”);
}
catch (Exception e) {
// Throwing an exception
System.out.println(“Exception is caught”);
}
}
}

ORR

// Implement Runnable interface
class MultithreadingDemo implements Runnable {
public void run()
{
try {
// Displaying the thread that is running
System.out.println(
“Thread “ + Thread.currentThread().getId()
+ “ is running”);
}
catch (Exception e) {
// Throwing an exception
System.out.println(“Exception is caught”);
}
}
}

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

synchronised *Java keyword

A

prevents method from being executed until the previous call to the same method ends

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

why separate design and implementation?

A

interfaces and abstract classes are used for design, you can change implementation independently of interface

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

static *Java keyword

A

static member variables can be accessed without creating object, static resources are shared with objects of same class

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

git init

A

turn local directory into git repository

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

.gitignore

A

lists files that cannot be committed

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

staging

A

git add <file>
#prepare file to be committed
git reset</file>

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

git stash

A

stores temporary changes for later
git stash pop
git checkout – <file></file>

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

branching

A

allows you to track multiple versions of the files in your repo
master is the primary branch

git branch (list branches)
git branch <name> (create branch)
git checkout <name> (switch branch)
git merge <name> (merge branch with current branch)</name></name></name>

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

git remotes

A

allow you to have multiple copies of your repo on different computers and servers
origin – name of primary remote

git remote -v (list remotes)
git remote add <remote_name> <url>
git pull <remote_name> <branch>
git push <remote_name> <branch></branch></remote_name></branch></remote_name></url></remote_name>

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

How do you share updated code with teammates in git?

A
  1. save changes
  2. add/stage changes
  3. commit changes
  4. pull
  5. resolve merge conflicts
  6. push
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How do you resolve a merge conflict on git?

A
  1. manually fix all files
  2. git commit
  3. save log file and exit text editor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

How do you safely merge feature branch to team’s development branch?

A
  1. checkout feature branch
  2. merge with development branch
  3. resolve merge conflicts, commit
  4. checkout development branch
  5. merge with feature branch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

When should you create an issue on GitHub?

A

you encounter bug, you see ugly code, you want to optimise existing code, you want to add a new feature, you want to build a test for an existing feature

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

issue tracking

A

a system for managing and tracking lists of issues, bugs and tasks

34
Q

pull request

A

a request to merge local branch into a remote branch
1. assign reviewer to review your pull request
2. reviewer makes comments
3. improve code, commit, push
4. reviewer approves code
5. merge pull request

35
Q

Example of a git workflow

A
  1. bug in code
  2. issue created, you are assigned
  3. create local feature branch
  4. fix bug, commit changes
  5. merge most recent version of development branch into feature branch
  6. push feature branch
  7. pull request …
  8. merge pull request
  9. close issue
36
Q

Waterfall - linear model for development (RADCTO)

A

Requirements: for system
Analysis: data, models, risks
Design: for software architecture
Coding: actually build solution
Testing: find and fix bugs
Operations: install, support, maintain

37
Q

Agile

A

self organised, cross functional teams
advocates for adaptive planning, evolutionary development, early delivery, continual improvement, rapid and flexible change

38
Q

Scrum (product owner - development team - scrum master)

A

continually submit product increments through a repeated process that includes planning, backlogging, communication, development and review

39
Q

Scrum stories

A

user description of a product feature

40
Q

Scrum sprints

A

basic unit of development (has duration)

41
Q

Scrum backlog

A

items that need to be done in future sprints

42
Q

html coding example

A

<!DOCTYPE html>

<html>
<head>
<title>My page</title>
<link></link>
</head>
<body>
<div>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</div>
</body>
</html>

43
Q

how do you access specific page elements using JavaScript?

A

document.getElementById

44
Q

What is a client? What is a server?

A

Client: client-side application (HTML, CSS, JS), personal device
Server: server-side code, server management software, file system, database

45
Q

requests

A

client sends a request to server and server eventually sends back response (requests are sent to endpoints)

46
Q

HTTP POST

A

sends data to server

47
Q

HTTP GET

A

request data from specified resource

48
Q

HTTP headers

A

used to pass additional information between clients and server through request and response header

49
Q

request header

A

GET /home.html HTTP/1.1
Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/testpage.html
Connection: keep-alive
Upgrade-Insecure-Requests: 1
If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT
If-None-Match: “c561c68d0ba92bbeb8b0fff2a9199f722e3a621a”
Cache-Control: max-age=0

50
Q

response header

A

200 OK
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Mon, 18 Jul 2016 16:06:00 GMT
Etag: “c561c68d0ba92bbeb8b0f612a9199f722e3a621a”
Keep-Alive: timeout=5, max=997
Last-Modified: Mon, 18 Jul 2016 02:36:04 GMT
Server: Apache
Set-Cookie: mykey=myvalue; expires=Mon, 17-Jul-2017 16:06:00 GMT; Max-Age=31449600; Path=/; secure
Transfer-Encoding: chunked
Vary: Cookie, Accept-Encoding
X-Backend-Server: developer2.webapp.scl3.mozilla.com
X-Cache-Info: not cacheable; meta data too large
X-kuma-revision: 1085259
x-frame-options: DENY

51
Q

AJAX

A

technique for accessing web servers from a web page

52
Q

Flask

A

Python module that turns computer into local server (python files, templates, static, private)

53
Q

Other common web development stacks?

A

LAMP (Linux Apache MySQL PHP)
MEAN (MongoDB Express.js Angular.js Node.js)

54
Q

plain text *data format)

A

VARIABLE : Mean TS from clear sky composite (kelvin)
FILENAME : ISCCPMonthly_avg.nc
FILEPATH : /usr/local/fer_dsets/data/
SUBSET : 93 points (TIME)
LONGITUDE: 123.8W(-123.8)
LATITUDE : 48.8S
123.8W
23
16-JAN-1994 00 / 1: 278.9
16-FEB-1994 00 / 2: 280.0
16-MAR-1994 00 / 3: 278.9
16-APR-1994 00 / 4: 278.9
16-MAY-1994 00 / 5: 277.8
16-JUN-1994 00 / 6: 276.1

55
Q

CSV *data format

A

Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar

56
Q

JSON *data format

A

[ {“name”:”Ram”, “email”:”Ram@gmail.com”}, {“name”:”Bob”, “email”:”bob32@gmail.com”} ]

57
Q

XML *data format

A

<?xml version=”1.0”?>

<catalog>
<book>
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
</catalog>

58
Q

SQL

A

CREATE TABLE MACHINES (name TEXT NOT NULL PRIMARY KEY,
category NOT NULL, photo NOT NULL, instructions NOT NULL);

INSERT INTO MACHINES (name, category, photo, instructions, id) VALUES (“Treadmill”, “Cardio” …);

SELECT * FROM MACHINES WHERE name=”Treadmill”;

59
Q

web scraping

A

server makes requests to other website or external server

60
Q

What are the benefits of following a code style?

A

Readability (and presentation)
Maintainability
Debugging
Consistency
Avoid danger
Simplify
Compatibility
Performance (and repeatability)
Search-ability
Standardisation

61
Q

obfuscation

A

Making your code incomprehensible or unreadable

62
Q

minification

A

Reducing the length of your code

63
Q

watermarking

A

Hiding information in your code

64
Q

What are the three kinds of software design patterns?

A

help solve common design problems
1. creational: for object creation mechanisms
2. structural: for realising relationships between objects
3. behavioral: for communication between objects

65
Q

singleton

A

creational design pattern: design class that can only be instantiated once

  • create something accessible everywhere in code
  • guarantee always accessing same thing (not a copy)
  • great for abstracting hardware components and system resources
    EX: system log, renderer, GPU, audio device
66
Q

implement singleton in Java

A

public class AudioDevice {

// Member variables
private int volume;
private int numOfInputChannels;

// A reference to the one and only AudioDevice
private static AudioDevice instance = null;

// The private constructor limits the creation of the AudioDevice
// You can only create an AudioDevice from within this class
private AudioDevice() {
    volume = 100;
    numOfInputChannels = 4;
}

// This method allows you to access the one and only AudioDevice
// and use it in the outside world
public static AudioDevice getInstance() {
    if (instance == null) {
        instance = new AudioDevice();
    }
    return instance;
}

public void decreaseVolume() {
    volume--;
}

public void increaseVolume() {
    volume++;
}

public String toString() {
    return "volume = " + volume + ", numOfInputChannels = " + numOfInputChannels;
}

}

67
Q

builder

A

creational design pattern: allows us to create objects more easily

  • Constructors can have a lot of parameters (10, 20, 50, or even 100)
  • It’s hard to keep track of all of them
  • It’s easy to mix up their ordering which leads to bugs

BAD because it causes an error when two different threads are both using the builder

68
Q

implement builder

A

// This is just one approach for implementing the builder design pattern.
// Another approach could treat the builder as an external object
// to avoid synchronization issues.
public class Employee {
private int id;
private String firstName;
private String lastName;
private String address;
private String phoneNumber;

private Employee(int id, String firstName, String lastName, String address, String phoneNumber) {
    this.id = id;
    this.firstName = firstName;
    this.lastName = lastName;
    this.address = address;
    this.phoneNumber = phoneNumber;
}

public static class Builder {
    private static int id;
    private static String firstName;
    private static String lastName;
    private static String address;
    private static String phoneNumber;

    public static void resetToDefault() {
        id = -1;
        firstName = "John";
        lastName = "Smith";
        address = "1000 Penn Ave";
        phoneNumber = "555 - 555 5555";
    }

    public static void setId(int id) {
        Employee.Builder.id = id;
    }

    public static void setFirstName(String firstName) {
        Employee.Builder.firstName = firstName;
    }

    public static void setLastName(String lastName) {
        Employee.Builder.lastName = lastName;
    }

    public static void setAddress(String address) {
        Employee.Builder.address = address;
    }

    public static void setPhoneNumber(String phoneNumber) {
        Employee.Builder.phoneNumber = phoneNumber;
    }

    public static Employee build() {
        return new Employee(id, firstName, lastName, address, phoneNumber);
    }
}

public String toString() {
    return id + ", " + firstName + ", " + lastName;
}

}

69
Q

abstract factory

A

creational design pattern: an abstract factory allows us to create many factories with competing products

  • We can create factories for both brands
70
Q

implement abstract factory

A

public abstract class Factory {

int id;

public Factory(int id) {
    this.id = id;
}

public abstract Button createButton();

public abstract TextInput createTextInput();

}

public class MacFactory extends Factory {

public MacFactory(int id) {
    super(id);
}

@Override
public Button createButton() {
    return new MacButton();
}

@Override
public TextInput createTextInput() {
    return new MacTextInput();
}

}

71
Q

decorator

A

structural design pattern: add additional functionalities on top of an existing object

  • Given a large catalog of possible functionalities, we can stack / nest them in any combination
  • Great for building pages / frames / UI components with styling
72
Q

implement decorator

A

abstract public class HTMLDecorator {
protected HTMLDecorator innerDecorator;

public abstract String outputString(String input); }

public class UnderlineDecorator extends HTMLDecorator {

public UnderlineDecorator(HTMLDecorator decorator) {
    this.innerDecorator = decorator;
}

@Override
public String outputString(String input) {
    return "<u>" + innerDecorator.outputString(input) + "</u>";
}

}

73
Q

bridge

A

structural design pattern
- There are many different kinds of computer hardware
- You might want the implementation of something to change if your system includes specialized hardware
- A different implementation could improve performance with specialized hardware like GPU’s
- Also, you might want a different implementation to avoid using a proprietary library

74
Q

implement bridge

A

public interface CalcMotionImpl {

public MotionPlan calculateMotion();

}

public class GPUCalcMotionImpl implements CalcMotionImpl {

public MotionPlan calculateMotion() {
    System.out.println("Do something else");
    return new MotionPlan();
}

}

75
Q

iterator

A

behavioural design pattern: iterate through elements in a data structure, database, or file

  • We want an easy way to iterate over elements from a data structure, database, or file
  • It does not require us to understand how the underlying structure works
  • Decouples algorithms for getting the data from algorithms that use the data
76
Q

implement iterator

A

import java.util.Iterator;

public class ForwardIterator<E> implements Iterator<E> {</E></E>

Node<E> nextNode;

public ForwardIterator(Node<E> startNode) {
    nextNode = startNode;
}

@Override
public boolean hasNext() {
    return nextNode != null;
}

@Override
public E next() {
    E element = nextNode.element;
    nextNode = nextNode.next;

    return element;
}

}

77
Q

visitor

A

behavioural design pattern: add additional functionality to a class

  • We want to extend a class’s functionality without modifying it
    • First, we make the class accept additional functionality
    • Then, whenever we want to add a new functionality, we create a new visitor for it
    • Finally, we can externally keep track of these additional functionalities
78
Q

implement visitor

A

public class PairOfIntegers extends Element {

public Integer leftInteger;
public Integer rightInteger;

public PairOfIntegers(Integer left, Integer right) {
    leftInteger = left;
    rightInteger = right;
}

public String toString() {
    return "(" + leftInteger + ", " + rightInteger + ")";
}

}

public class SwappingVisitor extends Visitor {

@Override
public void visit(Element element) {
    if (element instanceof PairOfIntegers) {
        PairOfIntegers pair = (PairOfIntegers) element;
        Integer temp = pair.leftInteger;
        pair.leftInteger = pair.rightInteger;
        pair.rightInteger = temp;
    } else {
        throw new IllegalArgumentException("element must be of type PairOfIntegers.");
    }
}

}

79
Q

class diagram
(structure diagram)

A

Shows the structure of a system by displaying objects and their relationships to each other (is-A, has-A)

https://online.visual-paradigm.com/diagrams/features/class-diagram-software/

80
Q

sequence diagrams
(behaviour diagram)

A

Shows how objects interact over time

https://online.visual-paradigm.com/diagrams/features/sequence-diagram-software/

81
Q

state diagram
(behaviour diagram)

A

Shows how a device, program, or process works
It includes states and transitions
Events trigger transitions from one state to another

https://online.visual-paradigm.com/diagrams/features/state-machine-diagram-software/

82
Q
A