Exam 1 Flashcards

1
Q

Abstraction

A

Provide high-level model of activity or data

Don’t worry about the details; What does it do, not how

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

Procedural Abstraction

A

Specify what actions should be performed

Hide algorithms

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

Data Abstraction

A

Specify data objects for problem

Hide Representation

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

Abstract Data Type (ADT)

A

Implementation independent of interfaces

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

Encapsulation

A

A design technique that calls for hiding implementation details while providing an interface (methods) for data access

Allows us to code without having to know its implementation
Change the internals all you want, but just keep the interface constant

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

Interfaces

A

Allows us to express an ADT
Provides abstract methods
Defines an IS-A relationship

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

Class

A

Blueprint for an object

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

a.compareTo(b) returns?

A

Negative if a < b
0 if a == b
Positive if a > b

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

Inheritance

A

The process by which one new class, called the derived class (subclass/child class), is created from another class, called the base class (superclass/parent class)

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

extends

A

Specifies that a class is a derived class of another class

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

super()

A
refers to the parent class object
calls the constructor of the parent class
Must be the first line in the child class' constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Overriding

A

A derived class redefines existing methods of the parent class

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

Overloading

A

When two or more methods have the same name but different parameters

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

this

A

refers to the current object

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

Protected

A

a class element that is only accessible to any derived class or any class in the same package

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

Early (static) binding

A

method that is called depends on the declared type of the referring variable, and not the object’s actual type

17
Q

Late (dynamic) binding

A

method that is called depends on an object’s actual type, and not the declared type of the referring variable

18
Q

Does java use early or late binding

A

Late binding

19
Q

Polymorphism

A

When a single reference variable refers to objects of many different types

20
Q

Upcasting

A
Casting a reference to a parent class
This is done automatically and is always safe
21
Q

Downcasting

A
casting a reference to a child class
May not be legal depending on the actual object type
You can force it by performing an explicit cast
22
Q

What does a ClassCastException mean?

A

Illegal downcasting occurred

23
Q

what is the stack

A

makes possible method execution

makes recursion possible

24
Q

what is the heap

A

where objects are created

25
Q

Recursion

A

A procedure that calls itself

Relies on the call stack

26
Q

Abstract methods

A

Give a signature but no body

Class descendants provide the implementation

27
Q

Abstract class

A

required if class contains any abstract method

28
Q

Program Correctness

A

determined by the presence/absence of program defects (errors/bugs)

29
Q

Types of program errors

A

Compile-time
Run-time
Logic

30
Q

Compile-Time errors

A

Detected during compilation

Lexical, grammatical, type errors

31
Q

Run-time errors

A

Detected during program execution

Operations are illegal/impossible to run

32
Q

Logical errors

A

Operation leading to incorrect program state

Problem in design or implementation of algorithm

33
Q

Reference copy

A

Makes copy of reference

x = y

34
Q

Shallow Copy

A

Makes copy of object

x = y.clone();

35
Q

Deep Copy

A

Makes copy of object and all objects directly or indirectly referred to by the object

36
Q

Cloning

A
We can create a copy of an object using the clone() method
Object class provides a clone() method that provides shallow copying
37
Q

Initialization Block

A

Block of code used to initialize static and instance variables for class

38
Q

Static Initialization Block

A
Executed only once
Code executed before class is used