MidTerm Exam Flash Cards

(60 cards)

1
Q

What does the toString() method return?

A

It returns a String representation of the Object.

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

What does the equals(otherObject) do?

A

It is a method compares an Object to otherObject and returns true if both variables reference the same object

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

What is a try block?

A

Surrounds normal code, which is exited immediately if the block throws an exception

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

What is a catch block?

A

A catch block catches an exception thrown in a preceding try block

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

A catch block is also called…

A

An exception handler

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

What is a FileNotFoundException?

A

Attempt to open a file denoted by a filename failed

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

What is EOFException?

A

End of file or end of stream has been reached unexpectedly

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

What is an ArrayIndexOutOfBoundsExcepton?

A

An array has been accesed with an illegal index

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

What is an InputMismatchException?

A

Received input does not match expected type or the input is out of range for the expected type

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

What is an ArithmeticException?

A

Arithmetic condition failed

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

What does null mean?

A

null is a special value indicating a pointer points to nothing

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

What is the first node called?

A

Head

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

What is the last node called?

A

Tail

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

What does append() mean? Where is the element added?

A

Add a new element and the tail points to the new node

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

What is prepend()? Where is the element added?

A

Adds the new node before the list’s head

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

How to prepend to an empty list?

A

Check if the list’s pointer head is empty.
Point the head to the new node

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

How to prepend to a non-empty list?

A

Check if the head not null(not empty)
point the new node to the head node

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

Removing a node:
ListRemovesAfter(numsList, node 5).
What happens to the node?

A

The node that it points to is removed

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

What is removed?
ListRemoveAfter(numsList, null)

A

If the curNode is null, it removes the head node

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

True or False.
If the current node is null does it remove the head?

A

True.

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

Where does a search start?

A

At a lists head

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

What happens when no match is found?

A

Null is returned

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

When swapping 2 variables what other variable must you use?

A

A temp variable

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

When reversing a list what happens?

A

The outer most elements are swapped all the way until the middle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the sort() method do?
Sorts collections into ascending order
26
True or False. An interface cannot be instantiated.
True.
27
What is it called when you have 2 methods with the same name within a class?
Overloading
28
What does the == operator do?
Checks the memory location of the 2 objects
29
True or False? Primitive variables represent the value itself not the address
True
30
When do you use the equals() method?
Use it to compare the objects
31
What does double mean?
It is another method to float and integer
32
When you don't know what a generic type is going to be?
Use in the generic to make sure it can pass anything
33
What does this ++ operator do
It increments the value by 1
34
What does -- operator do?
Decreases the the value of a variable by 1
35
What does thus logical operator do? !
Reverses the result, returns false if the result is true
36
What does this concat() method do?
It concatenates 2 strings together
37
What method do you use to return the index(position) of the first occurance of "e"
System.out.println(txt.indexOf("e"));
38
What does this += oparator do?
It adds to the given value in the stated variable
39
What does widening Casting mean?
It means to convert a smaller type to a larger type
40
What does narrow casting mean?
It means to compare a larger type to a smaller type
41
Single line comments are noted with...
// (2 slashes)
42
Multi-line comments start with...
/*
43
Multi-line comments end with...
*/
44
What is a subclass?
The child class that inherits from another class
45
What is a superclass?
The parent class meaning the class being inherited from
46
What does Polymorphism mean?
It means many forms and occurs when we have many classes that are related to each other by inheritance
47
What does this line of code do? x = myObj.nextInt()
It reads the users input
48
What is the Scanner class used for?
It is used to get user input and it is found in the java.util package
49
What does the nextLine() do?
Reads a Strng value from the user.
50
What does the nextInt() value do ?
It reads the int value from the user
51
True or False. An exception can be thrown inside a try-catch statement and the same exception can be caught within the try-catch statement.
True.
52
What does ADT stand for and what does it mean?
It stands for abstract data type and it is a collection of data along with operations that can be performed on the data
53
An interface must be implemented using what keyword?
Implements
54
What does an ADT do?
It specifically says what an operation does, not how it does it
55
What does the push() method do?
It adds an element at the top of a stack
56
What does the pop() method do?
It removes an element at the top of a stack
57
What type of Structure is a stack?
LIFO(Last In, First Out)
58
What is a stack?
It is a collection whose elements are added and removed from one end, called the top of the stack
59
What does the peek() method do?
Returns the element at the top of the stack without removing it
60
True or False. A stack can be empty.
True