MidTerm Exam Flash 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
Q

What does the sort() method do?

A

Sorts collections into ascending order

26
Q

True or False.
An interface cannot be instantiated.

A

True.

27
Q

What is it called when you have 2 methods with the same name within a class?

A

Overloading

28
Q

What does the == operator do?

A

Checks the memory location of the 2 objects

29
Q

True or False?
Primitive variables represent the value itself not the address

A

True

30
Q

When do you use the equals() method?

A

Use it to compare the objects

31
Q

What does double mean?

A

It is another method to float and integer

32
Q

When you don’t know what a generic type is going to be?

A

Use <?> in the generic to make sure it can pass anything

33
Q

What does this ++ operator do

A

It increments the value by 1

34
Q

What does – operator do?

A

Decreases the the value of a variable by 1

35
Q

What does thus logical operator do? !

A

Reverses the result, returns false if the result is true

36
Q

What does this concat() method do?

A

It concatenates 2 strings together

37
Q

What method do you use to return the index(position) of the first occurance of “e”

A

System.out.println(txt.indexOf(“e”));

38
Q

What does this += oparator do?

A

It adds to the given value in the stated variable

39
Q

What does widening Casting mean?

A

It means to convert a smaller type to a larger type

40
Q

What does narrow casting mean?

A

It means to compare a larger type to a smaller type

41
Q

Single line comments are noted with…

A

// (2 slashes)

42
Q

Multi-line comments start with…

A

/*

43
Q

Multi-line comments end with…

A

*/

44
Q

What is a subclass?

A

The child class that inherits from another class

45
Q

What is a superclass?

A

The parent class meaning the class being inherited from

46
Q

What does Polymorphism mean?

A

It means many forms and occurs when we have many classes that are related to each other by inheritance

47
Q

What does this line of code do?
x = myObj.nextInt()

A

It reads the users input

48
Q

What is the Scanner class used for?

A

It is used to get user input and it is found in the java.util package

49
Q

What does the nextLine() do?

A

Reads a Strng value from the user.

50
Q

What does the nextInt() value do ?

A

It reads the int value from the user

51
Q

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.

A

True.

52
Q

What does ADT stand for and what does it mean?

A

It stands for abstract data type and it is a collection of data along with operations that can be performed on the data

53
Q

An interface must be implemented using what keyword?

A

Implements

54
Q

What does an ADT do?

A

It specifically says what an operation does, not how it does it

55
Q

What does the push() method do?

A

It adds an element at the top of a stack

56
Q

What does the pop() method do?

A

It removes an element at the top of a stack

57
Q

What type of Structure is a stack?

A

LIFO(Last In, First Out)

58
Q

What is a stack?

A

It is a collection whose elements are added and removed from one end, called the top of the stack

59
Q

What does the peek() method do?

A

Returns the element at the top of the stack without removing it

60
Q

True or False.
A stack can be empty.

A

True