Final Superdeck Flashcards
Q1: Software development is all about learning a programming language.
False.
Q1: Object Oriented Programming is
A program consisting of classes and objects organized to manage the complexity of large-scale systems.
Q1: Procedural programming is
A program consisting of methods/functions calling each other.
Q1: A method ___
Implements behaviors relevant to the purpose of the system
Q1: A field or attribute ___
Stores data relevant to the purpose of the system
Q1: A container object
Data structure to store entities
Q1: A control object
Organize computation or flow of the program
Q1: An interface object
Facilitates communication between the system and the outside world
Q1: An entity object
Model of a real-world thing in an application
Q2: T/F A UML Use Case diagram is a type of behavioral diagram.
True.
Q2: In a UML Use Case diagram, what relationship is used in a situation where the execution of a use case ALWAYS involves the execution of an associated use case?
Include.
Q2: T/F A UML Class diagram is a type of behavioral diagram.
False.
Q2: Given three classes, plant, tree, and flower, which of the following best describes their relationship to each other?
Inheritance.
Q2: Given two classes, House and Wall, where the House is a container of Wall objects, what describes their relationship?
Composition.
Q2: Given two classes, Book and Bookshelf, what best describes their relationship?
Aggregation.
Q2: Given two classes, Hammer and Nail, what best describes their relationship?
Association.
Q3: What principle should be used to have a method have different behaviors depending on the class it’s invoked on?
Polymorphism.
Q3: What phrase/term is used to describe inheritance?
a ____ is a _____
i.e.
a cat is an animal
Q3: T/F Interface and inheritance are different names for the same concept.
False.
Q3: T/F. Polymorphism can be expressed in a UML diagram.
False.
Q3: What is the conceptual advantage to Polymorphism?
refactor ugly if and switch/case statements
Q3: What is the conceptual advantage to inheritance?
eliminate redundant code
Q3: What is the conceptual advantage to abstraction?
hide details and show the essentials; isolate the impact of changes
Q3: What is the conceptual advantage to encapsulation?
grouping related variables and functions together to reduce complexity and increase reusability
Q4: Is a String a primitive data type in Java?
No.
Q4: T/F All data types in Java are references to data allocated on the Heap.
False.
Q4: What Java data type is ideal for measurement data?
Double.
Q4: T/F. Both single and double quotes can denote a String literal in Java.
False.
Q4: What is the basic syntax for a for loop in Java?
for (int i=0; i<10; i++)
{
System.out.println(“hello world”);
}
Q6: What does toString() do in Java?
Lets programmers define a String representation of their class.
Q7: What is Validation in testing?
Any method to increase confidence in the correctness of a software system
Q7: What is an error?
The cause of an undesired behaviour or incorrect result
Q7: What is debugging?
Inferring the cause of undesired behaviour or incorrect results
Q7: What is a Fault?
An undesired behaviour or incorrect result
Q7: What is Automated testing?
The computer runs a script performing the tests
Q7: What is manual testing?
A human types some input into a program
Q7: What causes a fault?
An error.
Q7: What is coverage in testing?
How much of the code is tested.
Q7: What is a failure in testing?
The inability of the system to do what is required.
Q7: What is unintended behavior defined as?
A fault.
Q7: T/F It is possible for a code to have an error but cause no faults.
True.
Q7: T/F If there is no error in the code, there are no faults.
True.
Q7: T/F It’s possible for a fault to be observed but no error to cause it.
Falst.
Q7: T/F If’s possible for one error to produce multiple faults.
True.
Q7: When should testing code be removed from a class?
Never.
Q7: Is it okay to set private attributes to set up test cases?
Yes.
Q7: When should a regression test print the status?
Only when they fail. I.e. If all tests pass, they should print nothing.
Q8: What Java keyword indicates inheritance?
extends
Q8: T/F Polymorphism can be used with both inherited super types and implemented interface types.
True.
Q8: What are a few common methods inherited from the object class?
getClass(), equals(), toString()
Q8: T/F A downside of polymorphism is that once you have a container of the supertype, it is impossible to convert and object back to its original type.
False.
Q8: List of benefits of polymorphism.
Can reduce the amount of code that one needs to write.
It can make code simpler and more concise.
It reduces coupling.
It can make code more flexible/adaptable.
Q8: What keyword is used to define that a class used an interface in Java?
Implements.
Q9: What data structure in Java can hold primitive data types?
Array (although arrays can also hold objects).
Q9: T/F Array lists have fixed size.
False.
Q9: T/F Arrays can only hold primitives.
False.
Q9: T/F TreeMap and HashMap can be used interchangably.
True, since they implement the same interface (although their performance may differ).
Q9: Which data structure is good for things being sorted and accessing things by their name?
TreeMap
Q9: Which data structure is good for needing to frequently inserting and removing from a a list.
LinkedList.
Q10: T/F Collections classes are defined using generic typing.
True.
Q10: T/F Generic types can be restricted to supertypes such as classes or interfaces.
True.
Q10: The comparable interface lets instances of the same class be compared with < and >.
False.
Q10: Java will automatically generate rules for comparisons between objects when implementing the Comparable interface.
False.
Q11: T/F after catching an exception, the program continues where the exception was originally thrown.
False.
Q11: T/F An exception should be thrown if a user enters bad/incorrect data.
True.
Q11: T/F An exception should be thrown if a regression test fails.
False.
Q11: T/F An exception should be thrown if a bug is detected in the program.
False.
Q11: T/F An exception should be thrown if a parameter violates a stated precondition.
True.
Q11: What is the best place to catch and handle an exception?
The method with enough information to effectively handle the exception.
Q11: T/F A try-catch statement can catch multiple different types of exceptions from the same try block.
True.
Q11: T/F code will NOT compile if you don’t try to catch a potential checked exception.
True.
Q12: What is used to create a pop-up dialog box to prompt the user to enter text?
JOptionPane.showInputDialogue()
Q12: What is used in Java Swing to represent the application’s window?
JFrame
Q12: T/F JFrame is a component.
False.
Q12: What is used in Java Swing to contain other components?
JPanel.
Q12: T/F we can create a custom window/frame by making a class that inherits from JFrame.
True.
Q13: In the event delegation model, what is a JButton?
An Event Source.
Q13: If you want to respond to a button click, what describes the process (as in the lecture).
Create a class that implements the ActionListener interface.
Q13: T/F An anonymous inner class can be defined without needing to assign the class name.
True.
Q15: T/F A goal of software design is to maximize cohesion.
True.
Q15: T/F A goal of software design is to maximize coupling.
False.
Q15: T/F A design pattern and algorithm are the same thing.
False.
Q15: What type of design pattern is the Singleton Pattern?
Creational.
Q15: What are the features of the Singleton Pattern?
Guarantees at most one instance of the class can exist in the system.
Provides global access to the object instance.
Q15: T/F A static method can access both static and instance variables.
False.
Q15: What is done with the constructor in the Singleton Pattern?
It is made private.
Q16: What type of design pattern is the Factory Pattern?
Creational.
Q16: What is the main goal of the Factory pattern?
To abstract the creation of a class or a hierarchy of classes.
Q16: What is the issue of using strings as parameters to a factory?
Spelling errors are possible and easy to make.
Q16: What can a string be replaced with in the Factory pattern?
A Java enum
Q17: What type of design pattern is the Strategy Pattern?
Behavioural.
Q17: What is the main goal of the Strategy Pattern?
Define and encapsulate a family of algorithms to make them interchangeable in the program.
Q17: What is meant by the principle to program the the supertype, not an implementation?
Objects should be stored in the most general type possible.
Q17: What is meant by favor composition over inheritance?
In some cases, encapsulating behaviors as objects makes the program more flexible than using inheritance.
Q17: What are a couple in class/lecture/lab examples of candidates for the strategy pattern?
Choosing different routing algorithms in a map program.
Equipping different attacks/abilities to a game creature.
Q18: What are the three layers in the Three-Layer Architecture?
Presentation, Domain, System.
Q18: T/F The Command Pattern can be used to coordinate between the presentation and the domain layer.
True.
Q18: T/F Each layer in the Three-Layer Architecture can only call methods in the layer below.
True.
Q18: T/F The Observer Pattern is used to update the databases whenever classes in the Domain layer change.
False.
Q18: T/F The Three-Layer Architecture promotes increased cohesion by forcing classes to be focused on smaller tasks.
True.
Q19: What type of design pattern is the Command Pattern?
Behavioral.
Q19: What is the main goal of the Command Pattern?
To encapsulate a method for the purpose of storing actions in data structures.
Q19: T/F The command pattern uses inheritance instead of composition.
False.
Q19: how are individual commands in the Command Pattern abstracted?
Commands all implement the same ‘Command’ interface.
Q19: What are a couple examples from class for candidates for the Command Pattern?
Managing a Queue of web requests.
Implementing an ‘undo/redo’ system.
Q20: In the Observer pattern, what is the purpose of the Observer?
The classes that receive notifications/updates
Q20: In the Observer pattern, what is the purpose of the Subject/Observable?
The thing being observed
Q20: In the Observer pattern, what is the purpose of the Client/Driver?
Creates the objects and sets up the pattern
Q20: Recall the podcast distribution system example. What is the Observer, Subject, and Driver in this system?
Observer: The user that subscribes to the podcast and listens to it.
Subject: The publisher/creator. They notify the observer of new releases.
Client/Driver: The act of subscribing to the podcast.
Q20: What is the use of the UML ‘ball-and-socket’ notation?
Creating an interface to abstract/loosen coupling between two objects.
Q21: What design pattern is commonly used in the MVC architecture?
Observer pattern.
Q21: What is the responsibility of the model?
Perform the program’s business logic.
Update the View when the program’s data changes.
Q21: What is the responsibility of the controller?
Interprets user input through ActionListeners.
Call methods on the Model in response to user commands (i.e. translates events into messages for the model).
Q21: What is the responsibility of the View?
Generate ActionEvents in response to user interaction.
Visually present data to the user.
Q21: What part of the MVC is the Observer?
The View.
Q21: What part of the MVC is the Subject?
The Model.
Q21: When does the Model send an update to the View?
Every time the data changes.
Q22: To make a custom GUI element/widget, which class do we need to inherit from?
JComponent.