1/184
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What are the four pillars of OOP?
Encapsulation/Inheritance/Polymorphism/Abstraction
What is a programming paradigm?
The fundamental approach or style of programming that defines how to structure and conceptualize code
What does imperative programming focus on?
How to achieve a result by explicitly listing each step
What does declarative programming focus on?
What the result should be/without specifying exact steps
What is OOP centered around?
Objects comprised of data(attributes)and methods(functions)
What is functional programming centered around?
The evaluation of expressions using functions/avoiding changing state and mutable data
What are the three key principles of functional programming?
First-class functions/immutability/and pure functions
What is a first-class function?
A function treated like any other data type—passed as arguments/returned/and assigned to variables
What is a higher-order function?
A function that accepts or returns other functions
What is immutability?
Data cannot be changed after creation/new data must be created instead
What is a pure function?
A function whose output is determined only by its input/with no side effects
What is referential transparency?
An expression can be replaced with its output without changing program behavior
When was FP added to Java?
Java 8(2014)with lambda expressions and streams
What is a lambda expression?
A concise way of representing an anonymous(unnamed)function:(parameters)->body
What is a functional interface?
An interface with exactly one abstract method
What does BinaryOperator
Takes two operands of type T and produces a result of type T
What does Function
Takes an input of type T and returns a result of type R
What does Consumer
Takes an input of type T and returns void
What does Supplier
Provides(returns)a result of type T with no input
What does Predicate
A boolean-value test on a type T
What is a stream in Java?
A sequence of objects processed in a functional manner/not a data structure/computed on demand
What are intermediate stream operations?
Operations that return a new stream and are lazy(e.g./map/filter/sorted/distinct)
What are terminal stream operations?
Operations that consume the stream and produce a result(e.g./collect/reduce/forEach/count/anyMatch/allMatch)
What does map() do?
Transforms each element in the stream
What does filter() do?
Keeps elements matching a given predicate
What does distinct() do?
Removes duplicate elements(per Object.equals)
What does reduce() do?
Combines elements into a single result
What does anyMatch() do?
Returns true if any element matches the condition
What does allMatch() do?
Returns true if all elements match the condition
Why are streams called lazy?
They do no work until a terminal operation is invoked
What is the Observer pattern used for?
Notifying multiple objects automatically when a subject's state changes
What are the components of the Observer pattern?
A subject/an observer interface/and classes implementing that interface
What is the Strategy pattern used for?
Defining a family of interchangeable algorithms the client can choose at runtime
What are the components of the Strategy pattern?
A strategy interface/concrete strategies/and a context class
What is UML?
A standardized visual modeling language for software design—not a programming language
What is a class diagram?
A structure diagram showing classes/attributes/operations/and their static relationships
What are the three main compartments of a class diagram?
Class name/attributes/and operations
What is a use case diagram for?
Showing how users(actors)interact with the system to achieve goals
What is an activity diagram for?
Modeling procedural and parallel behavior/workflows/and branching logic
What is a state machine diagram for?
Modeling an object's behavior over time through states and transitions
What is a package diagram for?
Grouping classes into namespaces and showing dependencies between packages
What is a deployment diagram for?
Showing the physical layout—what software runs on what hardware
What is an association in UML?
A solid line showing classes are related(related to relationship)
What is a unidirectional association?
Only one class knows about the other(e.g./Customer knows Order/Order doesn't know Customer)
What is a bidirectional association?
Two classes linked as inverses/each knowing about the other
What is aggregation?
A has a whole-part relationship where the part can exist independently(open diamond on the whole)
What is composition?
A stronger consists of relationship where the part cannot exist independently(filled diamond on the whole)
What is generalization?
Inheritance—a parent-child is a relationship/shown as a solid line with a hollow arrowhead
What is realization?
A class implementing an interface/shown as a dashed line with a hollow arrowhead
What does multiplicity 1 mean?
Exactly 1
What does multiplicity * mean?
Zero or more with no upper limit
What does multiplicity 0..1 mean?
Zero or one
What is forward engineering?
Drawing a UML diagram before writing code
What is reverse engineering?
Drawing a UML diagram from existing code
What is a requirement?
A statement stakeholders agree must be true for the customer's problem to be adequately solved
What is requirements gathering?
Collecting information about what the system needs to do
What is requirements analysis?
Identifying/documenting/and validating the needs and expectations of the product
What is a utility class?
A stateless helper class/often with static methods
When should you use an instance variable vs a parameter?
Use instance variables when data is part of an object's state/otherwise prefer passing as parameters
What is the output of:numbers.stream().map(n->n2).reduce(0/Integer::sum)for[1/2/3/4/5]?
30—each number doubled/then summed
What is the output of:words.stream().filter(s->s.length()>=5).map(String::toUpperCase .sorted().collect(…)for[banana/apple/kiwi/pear/orange/grape]?
[APPLE/BANANA/GRAPE/ORANGE]—kiwi(4)and pear(4)are filtered out
What is the difference between map()and forEach()?
map()transforms each element and returns a new stream/forEach()performs an action on each element and returns void
What is the key difference between intermediate and terminal operations?
Intermediate operations return a new stream and are lazy/terminal operations consume the stream and produce a result
Can you call a terminal operation and then continue chaining?
No—once a terminal operation runs/the stream is consumed
What does collect(Collectors.toSet())do vs toList()?
toSet()returns a Set(removes duplicates)/toList()returns a List(preserves all elements
Which functional interface would you use to test a condition?
Predicate
Which functional interface would you use to produce a value with no input?
Supplier
Which functional interface would you use to consume an input with no return?
Consumer
What is the arrow token in a lambda?
The->separates parameters from the body:(params)->body
A stock-trading app needs:(1)multiple components auto-update when price changes/(2)traders choose different algorithms at runtime.Which patterns?
Observer for(1)/Strategy for(2)
What pattern is best for a GUI event listener system?
Observer—multiple components notified when an event/state changes
What pattern is best for a payment system with credit card/PayPal/and bank transfer?
Strategy—interchangeable algorithms chosen at runtime
In the Strategy pattern/what is the role of the context class?
It holds a reference to a strategy and delegates work to it/able to switch strategies dynamically
In the Observer pattern/what does the subject maintain?
A list of its observers and notifies them of state changes
What are the three components of the Observer pattern?
A subject/an observer interface/and concrete observer classes
What are the three components of the Strategy pattern?
A strategy interface/concrete strategy classes/and a context class
Which relationship uses an open diamond?
Aggregation—the part can exist independently of the whole
Which relationship uses a filled diamond?
Composition—the part cannot exist independently
Which relationship uses a solid linewith a hollow arrowhead?
Generalization(inheritance)—is a
Which relationship uses a dashed linewith a hollow arrowhead?
Realization(implementation)—can
A Library contains many Books/and a Book belongs to a Library.What type of association?
Bidirectional—both classes reference each other
A Customer knows its Order/butthe Order doesn't know the Customer.What type?
Unidirectional
CarTire cannot exist independently of Car.What relationship?
Composition(filled diamond on Car's side)
ElectricCar extends Car.What relationship?
Generalization(inheritance/is a)
What is multiplicity 1..?
One or more
What is the difference between forward and reverse engineering?
Forward=diagram before code/reverse=diagram drawn from existing code
What is the difference between structure and behavior diagrams?
Structure=static aspects(what is present/architecture)/behavior=dynamic aspects(what happens/functionality)
True or False:Messy code is okay to meet a deadline.You can clean it up later.
False
True or False:Keeping code clean at all times is not a cost effective solution.
False
True or False:Adding more staff can maintain productivity with messy code.
False
True or False:Productivity decreases asymptotically to zero over time with messy code.
True
True or False:Longer names are generally better than shorter names since they can give more context.
False
True or False:Class names should only be nouns.
True
True or False:Solution domain names are preferable to problem domain names to make it easier for the programmer.
False—problem domain names are preferred
True or False:Names should reveal intention.
True
True or False:Most names provide meaningful context in and of themselves.
False
True or False:Use encodings like member prefixes"m_"to distinguish names.
False
True or False:Different classes can use different words for the same concept.
False—be consistent across classes
True or False:Choosing good names requires a shared cultural background.
True
True or False:Names should vary in small ways.
False