Shared Flashcard Set

Details

Exam 1 Practice
Software Engineering
130
Computer Science
Undergraduate 2
10/21/2015

Additional Computer Science Flashcards

 


 

Cards

Term
Primitive types in Java may be mutable or immutable
Definition
F
Term
In C, if pointer p is set equal to array a, then *(p + 3) is effectively the same thing as a[3]
Definition
T
Term
Only checked exceptions are subject to the catch or specify requirement in Java
Definition
T
Term
Java reference types can always be extended
Definition
F
Term
Assertion checking is typically turned on during development and turned off after delivery
Definition
T
Term
TravList s = new AbstractTravList<>(); will NOT compile in Java
Definition
T
Term
StackTravList s = new StackTravList<>(); will NOT compile in Java
Definition
T
Term
A variable that is declared final in Java is effectively a constant
Definition
F
Term
The List method "contains" can be implemented using "IndexOf"
Definition
T
Term
It is reasonable to override a secondary method with a primary one if the primary method is more efficient
Definition
T
Term
The secondary List method addAll should probably be implemented in ArrayList and LinkedList rather than AbstractList
Definition
F
Term
One benefit of a Java interface is that the compiler can check to see if the interface methods have been implemented
Definition
T
Term
If you want to use a class in your Java application, the first thing you should do is look at the implementation (code) for the class
Definition
F
Term
If a hash table has 5 buckets (0-4), then the last digit of the hash codes in bucket 0 is either 0 or 5
Definition
T
Term
The UNIX command cp *.java ~ copies all java files from the current directory to the parent directory
Definition
F
Term
C or Java: Arrays can be declared either on the stack or the heap
Definition
C
Term
C or Java: Compiles to machine code
Definition
C
Term
C or Java: Periodically runs a garbage collector to free up unused memory
Definition
Java
Term
C or Java: Throws a runtime exception if array indexes are out of bounds
Definition
Java
Term
C or Java: Most operating systems are still written in this language due to its low-level capabilities
Definition
C
Term
C or Java: Can cause buffer overflow errors if programmers are not careful
Definition
C
Term
C or Java: Allows aliasing between mutable types
Definition
both
Term
C or Java: Distinguishes between primitive types and reference types
Definition
Java
Term
C or Java: Has a built-in mechanism for encapsulating data and their operations
Definition
Java
Term
C or Java: Allows users to write operation signatures in one file and implement them in another
Definition
both
Term
All immutable objects must be declared final in Java
Definition
F
Term
ArrayList s = new ArrayList<>(); will NOT compile in Java
Definition
F
Term
assert is a key word in Java that must always followed by a boolean expression
Definition
T
Term
Exceptions should not be used for flow-control
Definition
T
Term
FileNotFoundException is an example of a checked exception
Definition
T
Term
In C, you must declare variables at the beginning of a block. In Java, best practice is to declare variables close to where you use them.
Definition
T
Term
List s = new AbstractList<>(); will NOT compile in Java
Definition
T
Term
NullPointerException, IllegalArgumentException, and IllegalStateException are all examples of unchecked exceptions
Definition
T
Term
The final part of a try-catch block is always executed regardless of whether an exception is thrown or not
Definition
T
Term
The home directory in Unix is represented as two dots: ..
Definition
F
Term
C or Java: Allows fine-grained control over hardware
Definition
C
Term
C or Java: Allows programmers to access the 61st element of a 60 element array
Definition
C
Term
C or Java: Allows two different variables on the stack to access the same memory location in the heap
Definition
both
Term
C or Java: Arrays are always on the heap
Definition
Java
Term
C or Java: Catches null-pointer errors at compile time
Definition
C
Term
C or Java: Encapsulates data with operations that manipulate that data
Definition
Java
Term
C or Java: Has a boolean type
Definition
Java
Term
C or Java: Is subject to buffer overflow attacks
Definition
C
Term
C or Java: Requires programmers to declare functions/methods before using them
Definition
C
Term
C or Java: Requires programmers to manage (allocate and free) memory manually
Definition
C
Term
C or Java: Runs programs on a virtual machine
Definition
Java
Term
What is printed in the following code?
String[] text = new String[10];
System.out.println(text[0]);
A. Nothing - the array has not been initialized
B. Nothing - an out-of-bounds error will occur
C. Nothing - a null-pointer exception will occur
D. The empty string
Definition
A
Term
Give the condition that ensures the index variable i is within the legal bounds
A. 0 <= i < elements.length
B. 0 <= i < && i < elements.length()
C. 0 <= i < elements.length()
D. 0 <= i && i < elements.length
Definition
D
Term
Which statement declares and initializes an array of prime numbers?
A. int[] primes = {1, 2, 3, 5, 7}
B. int() primes = [1, 2, 3, 5, 7]
C. int[] primes = [1, 2, 3, 5, 7]
D. int() primes = {1, 2, 3, 5, 7}
Definition
A
Term
Which expression pair characterizes the first and last elements of an array list?
A. 0, list.length
B. 0, list.size()
C. 0, list.size() - 1
D. 1, list.size()
Definition
C
Term
Assume that "list" is an array list with at least one element. How can we remove the last element?
A. list[list.length - 1] = null;
B. list.get(list.size());
C. list.remove(list.last);
D. list.remove(list.size() - 1)
Definition
D
Term
Which statement inserts the first element in an array list?
A. list.insert(0, "John");
B. list.add(1, "John");
C. list.insert(1, "John");
D. list.add(0, "John");
Definition
D
Term
Suppose we have an array list named "list" whose representation is: elements --> [A B C D /]; size = 4; capacity = 5
What is the effect of calling list.remove(1) on the representation?
A. elements --> [A / C D /]; size = 3; capacity = 5
B. elements --> [A C D / /]; size = 3; capacity = 5
C. elements --> [/ B C D /]; size = 3; capacity = 5
D. elements --> [A B C / /]; size = 3; capacity = 4
Definition
B
Term
Suppose we have an array list named "list" whose representation is: elements --> [A B C D E]; size = 5; capacity = 5
What is the effect of calling list.add(X) on the representation?
A. elements --> [A B C D E X / / / /]; size = 6; capacity = 10
B. elements --> [A B C D E X]; size = 6; capacity = 6
C. elements --> [X A B C D E]; size = 6; capacity = 6
D. elements --> [A B C D E X]; size = 6; capacity = 5
Definition
A
Term
Which best describes what happens in the implementation of list.add(5, X) for an array list?
A. Elements moved right from 5 to size-1 and X inserted at 5
B. Elements moved right from size-1 to 5 and X inserted at 5
C. X inserted at 5 and elements moved right from 5 to size-1
D. X inserted at 5 and elements moved right from size-1 to 5
Definition
B
Term
What is the last copy in an ArrayList with 10 elements in list.remove(5)?
A. elements[5] is copied to the return value
B. elements[6] is copied to elements[5]
C. elements[9] is copied to elements[8]
D. elements[10] is copied to elements[9]
Definition
A
Term
How many nodes does a Java linked list have when it is empty?
A. None
B. One
C. Two
D. Ten
Definition
B
Term
Which is most appropriate to print out the elements of an ArrayList?
A. for(E elem : elements) System.out.println(elem);
B. for(int i = 0; i < elements.length; i++) System.out.println(elements[i]);
C. for(int i = 0; i < capacity; i++) System.out.println(elements[i]);
D. for(int i = 0; i < size; i++) System.out.println(elements[i]);
Definition
D
Term
What code might we see when printing elements of a non-empty LinkedList?
A. Node temp = header; while(temp != header) //print temp.contents
B. Node temp = header; for(int i = 0; i < size; i++) //print temp.contents
C. for(int i = 0; i < size; i++) //print header.contents[i]
D. Node temp = header.next; while(temp ! = header) //print temp.contents
Definition
D
Term
When we consider an abstract view of a linked list or array list, what do we NOT consider?
A. The efficiency of the operations
B. The behavior of the operations
C. Implementation details
D. A and C
E. B and C
Definition
D
Term
We might choose to use an array list over a linked list because we will NOT require frequent
A. Random access
B. Inserting new elements
C. Removing of elements
D. B and C
Definition
D
Term
Primary methods may be implemented in
A. Interfaces
B. Abstract Classes
C. Concrete Classes
D. B and C
Definition
C
Term
Secondary methods may be implemented in
A. Interfaces
B. Abstract Classes
C. Concrete Classes
D. B and C
Definition
D
Term
The new keyword in Java may be used in front of
A. Interfaces
B. Abstract Classes
C. Concrete Classes
D. B and C
Definition
C
Term
Doctor has field worksAtHospital and method treatPatient(). Surgeon extends Doctor, overriding treatPatient() and adding makeIncision(). How many fields and methods does Surgeon have?
Fields: A. 0 B. 1 C. 2 D. 3
Method: A. 0 B. 1 C. 2 D. 3
Definition
B, C
Term
Doctor has fields worksAtHospital and method treatPatient(). FamilyDoctor extends Doctor, adding field makesHouseCalls and method giveAdvice(). How many fields and methods does FamilyDoctor have?
Fields: A. 0 B. 1 C. 2 D. 3
Method: A. 0 B. 1 C. 2 D. 3
Definition
C, C
Term
If you declare a class T as final, you cannot reassign to any variables with type T.
Definition
F
Term
In Java, array always reside on the heap, but in C, arrays may reside on the heap or the stack.
Definition
T
Term
A variable's apparent type should be equal or be a subtype of its actual type.
Definition
F
Term
A Java class may implement multiple interfaces
Definition
T
Term
A checked exception must be caught or thrown further up the stack
Definition
T
Term
A primary method does not need to be implemented in a concrete class
Definition
T
Term
"hello" == new String("hello")
Definition
F
Term
If a Java array has length 5 and x is an int, then x%5 is a valid index in the array
Definition
T
Term
If x=8 is a Java int, the value of x<<2 is 2
Definition
F
Term
If x = true and y = false, then !(x&&y) is true
Definition
T
Term
(y/x>5||x==0) will throw an exception if x==0
Definition
T
Term
Interaction Design focuses on how people interact with technology
Definition
T
Term
An example of a physical constraint is that most pieces for a Lego motorcycle will only fit together one way
Definition
T
Term
An example of a cultural constraint is that a motorcycle rider needs to see where he is going, so he must face the front
Definition
F
Term
What some people consider human error is often the result of poor design.
Definition
T
Term
This component is the only major component that is NOT a child of the content pane
Definition
Menu Bar
Term
This component is typically used for entering a single line of text
Definition
Text Field
Term
This component sits between the top level component and most other components like buttons, labels, and text areas
Definition
Content Pane
Term
This layout manager is recommended for the most complicated layouts
Definition
GridBagLayout
Term
This layout puts components in a single row or column and typically respects requested maximum sizes
Definition
BoxLayout
Term
This method is called by repaint to update the display of graphical objects
Definition
paintComponent
Term
Use this listener to respond to a button click
Definition
ActionListener
Term
Use this listener to respond to mouse events such as pressing and releasing a mouse button
Definition
MouseListener
Term
A hashCode should be unique as possible, e.g., the hashCode for "tea" should not be the same as the hashCode for "eat"
Definition
T
Term
ArraySet and ListSet are two of the most common implementations for Sets in Java
Definition
F
Term
If a.equals(b) is true, then a.hashCode() == b.hashCode() should also be true
Definition
T
Term
In a hash table with 10 buckets (0-9), the bucket that holds an object equals the last digit of the object's hashCode
Definition
T
Term
To modify a key-value pair in a Java Map, you use the same method as you do to add a new key-value pair to the Map
Definition
T
Term
TreeSet is used for Sets that need to be maintained in sorted order
Definition
T
Term
In the Java collections framework, which pattern allows programmers to use the enhanced for-loop?
Definition
Iterator
Term
In the Java GUI framework, which pattern allows objects to listen for GUI events?
Definition
Observer
Term
In the Java IO framework, which pattern lets you wrap readers and writers in other readers and writers?
Definition
Decorator
Term
This pattern converts the interface of a class into another interface the clients expect
Definition
Adapter
Term
This pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime
Definition
Strategy
Term
This pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate
Definition
Factory
Term
This pattern ensures that a class has only one instance and provides a global point of access to it
Definition
Singleton
Term
This pattern ensures that when one object changes state, all dependents are notified and updated automatically
Definition
Observer
Term
This pattern lets clients treat individual object and groups of objects uniformly
Definition
Composite
Term
This pattern provides access to elements of an aggregate object without exposing its underlying representation
Definition
Iterator
Term
This pattern wraps an object, allowing you to attach additional functionality to it dynamically
Definition
Decorator
Term
Decide how much time and money will be spent
Definition
Estimation
Term
Decide what the software will do
Definition
Requirements Gathering
Term
Specify objects in the problem domain
Definition
OO Analysis
Term
Specify software objects and how they collaborate
Definition
OO Design
Term
Developers actually write the code
Definition
Implementation
Term
Verification and validation take place
Definition
Testing
Term
Enhancement, bug fixes, and adaptation to new environments
Definition
Maintenance
Term
A disciplined technique for strengthening the internal design of existing code without affecting functionality
Definition
Refactoring
Term
A good rule of thumb is that the size of these should be about the same size as your production code
Definition
Unit Tests
Term
Allows you to quickly detect any defect that may have been introduced when you are changing things
Definition
Regression Testing
Term
If you can't build all you intended, you must slip functionality; you must not slip the delivery date
Definition
Time-Boxing
Term
Involves a fully automated build process that begins when any team member checks code into a code base
Definition
Continuous Integration
Term
This type of software used to keep track of changes to the code
Definition
Version control
Term
Barbs on barbed-wire fence: False/Anti/Invisible Affordance or Signifier?
Definition
Anti-Affordance
Term
Beware of dog sign: False/Anti/Invisible Affordance or Signifier?
Definition
Signifier
Term
High-voltage wire: False/Anti/Invisible Affordance or Signifier?
Definition
Invisible anti-affordance
Term
Placebo button: False/Anti/Invisible Affordance or Signifier?
Definition
False affordance
Term
This UML diagram depicts which method calls which other methods during a particular run of the system
Definition
Use Case
Term
This UML diagram describes how events make changes (transitions) to a system over its lifetime
Definition
State
Term
This UML diagram describes the static relationships that exist between components of a system
Definition
Class
Term
This UML diagram is similar to a flow chart
Definition
Activity
Term
This UML diagram shows how external entities interact with various system requirements
Definition
Component
Term
This UML diagram shows you the physical location of software components
Definition
Deployment
Term
This UML diagram uses special columns to indicate who performs a particular activity
Definition
Swim-Lane
Supporting users have an ad free experience!