Crying for Midterm 1 Flashcards

1
Q

The Metaphor of the Object_Oriented Paradigm

A

Everything is an object
A class is a collection of objects

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

Implementor, Client, Designer

A

Implementor: Formulates the algorithms
Client: instantiates objects and uses methods
Designer: defines abstractions and chooses interfaces

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

Abstraction

A

Polymorphism; specifically how it can relate to inheritance and such

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

Composition

A

The idea of objects attributes being other objects

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

Attributes, Methods, and Constructors

A

Attributes: data stored inside of an object
Methods: Behaviors stored inside of objects/classes used to instantiate the objects
Constructors: only available in Classes, used to instantiate objects themselves (making sure they are stable)
Encapsulation is a common theme with attributes and methods

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

Definitions of an “interface”

A
  1. GUI that we all know and love
  2. Java keyword interface
  3. The interactions between Objects and Classes and their respective interfaces
  4. The Java API
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Packages

A

A storage system used to group together different classes into different positions on a computer.
Classes within the same package can use protected variables
Allows two classes to have the same name but different locations, making “overloading” names possible

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

Design: object responsibilities

A

An objects responsibility is to be stable, have a relatively discrete interface, and to do it’s job and only it’s job.
Objects should have private attributes exclusively.
Objects should have attributes to display necessary information within the general interface.

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

Abstract classes

A

CANNOT have constructors
used as a midway between classes and interfaces
can have instance variables
single inheritance
can be made up of abstract methods and normal methods

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

Abstract methods

A

methods that consist of only a return type, name, and parameters
Need to be overloaded in child classes w/ methods

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

Classes

A

a blueprint for objects
used to define everything that specific object would and could ever need
must have a constructor (if not given one the Java JVM makes one anyways)

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

Interfaces

A

CANNOT have a constructor
CANNOT have instance variables
CAN have constant variables
supports multiple implementations
All implementing classes must include all methods present within the interface
All interface methods MUST be abstract

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

Polymorphism

A

The act of overriding methods in child classes to make them more personal for each specific object
Insanely powerful
When you call a method, you will get specifically the most specific instance of that method if it applies to the object in question

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

Exceptions

A

The act of managing things that go wrong in code.

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

Unchecked exceptions

A

Exceptions caused by errors present within the implementation that can be fixed by better coding logic

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

Checked Exceptions

A

Exceptions caused by things that go wrong during runtime (I/O errors, FileNotFoundExceptions, etc)

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

throws keyword

A

Belongs in method signature
used on all methods that throw an exception.
NOT used in try-catch methods within the main method to test code

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

throw keyword

A

Belongs in method body
Throw new exception(“String”)
if it is present in the method body, you must use throws in the signature

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

Hoare’s Consequence

A

You can override a method by doing the following:
1. Have less or the same outputs
2. Have more or the same inputs

20
Q

Obligations and Benefits of Design by Contract

A

Client Obligations:
makes sure the inputs and legal
Client Benefits:
doesn’t have to worry about implementation
Implementor Obligations:
ensures the code works to the desired output
Implementor Benefits:
doesn’t have to worry about defensive coding

21
Q

Preconditions

A

A condition that MUST be true for your code to work (normally regarding the input the user gives)

22
Q

Postconditions

A

A condition that MUST be true for the output your code gives

23
Q

Requires

A

The formal language for Precondition

24
Q

Ensures

A

The formal language for Postcondition

25
Q

JavaDocs

A

/** Done in this style of commenting
* can be used to publish pages of Javacode with explanations
*
*
*/

26
Q

@param

A

needed for each formal parameter

27
Q

@return

A

needed for the return type/value of the variable (if there is one)

28
Q

@requires

A

formal JavaDoc for the requires statement/precondition

29
Q

@ensures

A

formal JavaDoc for the ensures statement/postcondition

30
Q

Stages of Types of Testing

A

Development Testing

Release Testing

User Testing

31
Q

Development Testing

A

When you test the code during development
includes 3 methods:
Unit testing
Component Testing
System Testing

32
Q

Unit Testing

A

When you test individual classes or methods.
Can use Automated Tests which have 3 parts:
setup
call
assertion

33
Q

Setup

A

initialize the system with the outputs and excepted inputs

34
Q

Call

A

Call a method you’re testing

35
Q

Assertion

A

Compare the real output with the expected output

36
Q

Black Box testing

A

When you know the interface but not any implementation present about code

37
Q

White Box Testing

A

when you know the implementation of code you’re testing

38
Q

Component Testing

A

testing a couple of methods/classes and how they interact with eachother

39
Q

System Testing

A

when you test the entire system to see if it works properly

40
Q

Release Testing

A

When you test a complete version to see if it meets the requirements

41
Q

User Testing

A

basically beta testing

42
Q

JUnit

A

a popular form of automatic testing
imported library
includes
@BeforeEach // used before each statement before the test
@Test // used on every test

43
Q

Simple Assertions

A

tests a boolean condition, if false, the JVM stops with an error
assert booleanExpression;

44
Q

Complex Assertions

A

Tests a boolean condition, if false, JVM stops and prints a String
assert booleanExpression: String;

45
Q

Test Driven Development

A

When you write your tests before you fill out the implementation of your program