DATA STRUCTURES FINAL EXAM
STUDY GUIDE QUESTIONS AND
ANSWERS
What is an object? - Correct Answers -an instantiation of a class and a class defines the
structure of its objects
What does an object represent? - Correct Answers -An object represents Information
and behavior
Observers - Correct Answers -getters and accessors
Transformers - Correct Answers -setters and mutators
Class inheritance - Correct Answers -are organized in an "is a" hierarchy
What is a primitive variable? - Correct Answers -primitive data type
What is a reference variable? - Correct Answers -refers to a class or an array
What happened when insertion code is called when the linked list is empty? - Correct
Answers -The new node will become the first and only node on the linked list
What's an Abstract Data Type(ADT)? - Correct Answers -A data type whose
properties(domain and operations) are specified independently of any particular
implementation
What are the three levels in ADT? - Correct Answers -Logical, Implementation and
Application
What are the thee major phases of Java exception mechanism? - Correct Answers -
Defining the exception, generating the exception, handling the exception.
In which situations the array based implementation and the linked based
implementation are most suitable?
A. Unbounded Stack ADT and bounded Stack ADT, respectively
B. Unbounded Stack ADT and unbounded Stack ADT, respectively
C. Bounded Stack ADT and bounded Stack ADT, respectively
D. Bounded Stack ADT and unbounded Stack ADT, respectively
, E. They are equally suitable. - Correct Answers -D.Bounded Stack ADT and unbounded
Stack ADT, respectively
Which of the following represents "quadratic" time?
A. 3n+5n^2+1
B. nlogn
C. n7+n+1
D. 2^n+n^2+5
E. None of the above - Correct Answers -A.3n+5n2+1
Which of the following statements is TRUE about linked lists?
A. All the elements in a linked list are always stored contiguously.
B. Given the position, removing a node from a linked list is extremely inefficient.
C. Linked lists support random access.
D. You can traverse a singly linked list from head to tail and from tail to head.
E. Each node in a singly linked list saves data as well as a link to its next node. -
Correct Answers -E. Each node in a singly linked list saves data as well as a link to its
next node.
Which of the following Java statement attempts to invoke methods that would potentially
throw exception(s)?
A. throw
B. raise
C. catch
D. try
E. None of the above - Correct Answers -D. try
Given the following code snippet, what is the size of the stack after all this code
executes?
NumberStack
s.push(10);
s.push(20);
s.push(30);
s.push(40);
s.push(50);
s.pop();
int myInt = s.pop();
s.pop();
s.push(myInt);
A. 2
B. 3
C. 4
D. 5
E. none of the above - Correct Answers -B. 3
Which of the following structures did we classify as "non-linear"?
STUDY GUIDE QUESTIONS AND
ANSWERS
What is an object? - Correct Answers -an instantiation of a class and a class defines the
structure of its objects
What does an object represent? - Correct Answers -An object represents Information
and behavior
Observers - Correct Answers -getters and accessors
Transformers - Correct Answers -setters and mutators
Class inheritance - Correct Answers -are organized in an "is a" hierarchy
What is a primitive variable? - Correct Answers -primitive data type
What is a reference variable? - Correct Answers -refers to a class or an array
What happened when insertion code is called when the linked list is empty? - Correct
Answers -The new node will become the first and only node on the linked list
What's an Abstract Data Type(ADT)? - Correct Answers -A data type whose
properties(domain and operations) are specified independently of any particular
implementation
What are the three levels in ADT? - Correct Answers -Logical, Implementation and
Application
What are the thee major phases of Java exception mechanism? - Correct Answers -
Defining the exception, generating the exception, handling the exception.
In which situations the array based implementation and the linked based
implementation are most suitable?
A. Unbounded Stack ADT and bounded Stack ADT, respectively
B. Unbounded Stack ADT and unbounded Stack ADT, respectively
C. Bounded Stack ADT and bounded Stack ADT, respectively
D. Bounded Stack ADT and unbounded Stack ADT, respectively
, E. They are equally suitable. - Correct Answers -D.Bounded Stack ADT and unbounded
Stack ADT, respectively
Which of the following represents "quadratic" time?
A. 3n+5n^2+1
B. nlogn
C. n7+n+1
D. 2^n+n^2+5
E. None of the above - Correct Answers -A.3n+5n2+1
Which of the following statements is TRUE about linked lists?
A. All the elements in a linked list are always stored contiguously.
B. Given the position, removing a node from a linked list is extremely inefficient.
C. Linked lists support random access.
D. You can traverse a singly linked list from head to tail and from tail to head.
E. Each node in a singly linked list saves data as well as a link to its next node. -
Correct Answers -E. Each node in a singly linked list saves data as well as a link to its
next node.
Which of the following Java statement attempts to invoke methods that would potentially
throw exception(s)?
A. throw
B. raise
C. catch
D. try
E. None of the above - Correct Answers -D. try
Given the following code snippet, what is the size of the stack after all this code
executes?
NumberStack
s.push(10);
s.push(20);
s.push(30);
s.push(40);
s.push(50);
s.pop();
int myInt = s.pop();
s.pop();
s.push(myInt);
A. 2
B. 3
C. 4
D. 5
E. none of the above - Correct Answers -B. 3
Which of the following structures did we classify as "non-linear"?