Basics Flashcards

1
Q

What three properties makes a program good?

A
  1. It works
  2. easy to modify
  3. reasonably efficient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does an ADT stand for?

A

Abstract Data Type

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

What does an ADT separate?

A

Specification and implementation, which improves the reusability

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

What is specification in this context, and where does it lie?

A

“What kind of program we are looking at” & in the public external part

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

What is implementation in this context, and where does it lie?

A

“How the operations are performed” & in the private internal part

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

What does unboxing convert between?

A

Wrapper class(like Integer) to primitives(like int)

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

What does boxing convert between?

A

Primitives like double to wrapper class(Double)

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

What is an exception?

A

An event that occurs that disrupts flow of execution

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

What are the general steps of dealing with a potential in exception?

A
  1. )method causes exception
  2. )throws exception
  3. )handles exception
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the steps of throwing?

A

method on call stack where error happens throws exception then can be handled or passed down the call stack for later handling

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

What types of methods forward the exception?

A

Ones without an exception handler

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

What two types of exception handlers are there?

A
  1. )try/catch/finally block

2. )throws @ method header with throw new exception object

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

What three types of exceptions are there?

A
  1. unchecked/runtime
  2. error
  3. checked
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between checked and unchecked exceptions?

A

unchecked are checked at runtime while checked are not

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

For a sub and super class, which direction is generalization happening?

A

creating a super class from a sub class is an example of generalization?

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

Changing a wrapper class to a generic type E is an example of what?

A

generalization

17
Q

commenting improves what?

A

clarity and thus reusability

18
Q

What is a data structure?

A

A way to organize data

19
Q

when instantiating an object with a superclass what two ways are correct?

A
Subclass x = new Subclass()
Superclass x = new Subclass(), if the method requires a variable of type superclass
20
Q

What is the difference between a reference type and a primitive type?

A

a primitive type is Boolean, int, double.. and is the actual data, whereas a reference type is a pointer to a class or other piece of data

21
Q

Out of the three basic data structures, arrays, lists and trees, which are dynamic?

A

arrays, since they can’t change in size

22
Q

What is aliasing?

A

Two references that refer to the same piece of data

23
Q

What is the difference between performance and complexity?

A

performance is how much actual space is being taken up, while complexity is how much space/time is taken as the problem size grows

24
Q

What are basic operations and what are their complexities?

A

-arithmetic operations
-assignments
-writes
O(1)

25
Q

What is the worst case complexity?

A

The largest complexity an algorithm can have

26
Q

How is complexity expressed?

A

By big-O notation

27
Q

What doesn’t affect big-O?

A

low order terms, scaling and constants

28
Q

How is the exact complexity expressed?

A

T(N)

29
Q

When is a function T(N), O(F(N))?

A

if for c and all values of N greater than n, T(N) <= c * F(N)

30
Q

What is the average & best case complexity?

A

The usual complexity and the smallest that an algorithm can have, respectively

31
Q

What two different searches are there for an array?

A
  1. ) binary search

2. ) sequential search

32
Q

What is the time complexity of a sequential search?

A

O(N)

33
Q

When an array is sorted what search improves the complexity?

A

binary search with a complexity of O(logN)