1/153
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
[JAVA/COLLECTIONS] What is a Java Collection?
A collection is an object that stores multiple objects together. Collections are commonly used with generics to specify what type of object the collection stores.
[JAVA/COLLECTIONS] What are generics in Java collections?
Generics specify the datatype stored by a collection. For example, List
[JAVA/COLLECTIONS] Why do we use List
Collections store objects, not primitive types. Wrapper classes such as Integer, Long, Double, and Boolean are used instead of primitive types.
[JAVA/COLLECTIONS] Where are the Java Collections API classes and interfaces imported from?
Collections API types are generally imported from java.util.
[JAVA/COLLECTIONS] Why should you prefer an interface over a concrete collection type?
declaring the variable using the interface, such as List
[JAVA/COLLECTIONS] What is Iterable?
Many collections implement the Iterable interface. It defines data structures that can be traversed with iterator(), which returns an Iterator, and these collections can also be traversed with an enhanced for loop.
[JAVA/COLLECTIONS] How do you traverse a collection with an Iterator?
Call iterator(), then loop while hasNext() is true and retrieve each value with next().
[JAVA/COLLECTIONS] What are the main properties of a List?
A List is ordered and allows duplicate values. Elements can be accessed by index.
[JAVA/COLLECTIONS] What are common List methods shown in the slides?
Common methods include add(), get(), set(), remove(), size(), contains(), and clear().
[JAVA/COLLECTIONS] What are the differences between List, Set, and Map?
A List is ordered and allows duplicates. A Set stores unique elements and is not indexed. A Map stores key-value pairs and is part of the Collections API even though it does not inherit the Collection interface.
[JAVA/COLLECTIONS] What is a LinkedList?
A LinkedList stores elements through connected nodes. Java LinkedLists are doubly linked, so each node refers to the previous and next nodes.
[JAVA/COLLECTIONS] How does a Queue work?
A Queue follows FIFO order. offer() adds at the end, poll() removes from the front, and peek() looks at the front.
[JAVA/COLLECTIONS] What is a Deque?
A Deque is a double-ended queue. It extends Queue and allows adding or removing from both ends.
[JAVA/COLLECTIONS] What Deque methods should you know?
addFirst(), addLast(), removeFirst(), and removeLast() operate on either end and throw on failure. offerFirst(), offerLast(), pollFirst(), pollLast(), and peekFirst() provide queue-style alternatives. A Deque can also act like a stack with push() and pop().
[JAVA/COLLECTIONS] What are the main properties of a Set?
A Set stores unique elements, is not indexed, and its ordering depends on the implementation.
[JAVA/COLLECTIONS] What is the difference between HashSet, LinkedHashSet, and TreeSet?
HashSet is not ordered. LinkedHashSet keeps insertion order. TreeSet keeps elements sorted.
[JAVA/COLLECTIONS] What is a Map?
A Map stores key-value pairs. Keys are used to retrieve values, and putting a new value for an existing key replaces the old value.
[JAVA/COLLECTIONS] What are common Map methods shown in the slides?
Common methods include put(), get(), containsKey(), containsValue(), remove(), size(), and isEmpty().
[JAVA/COLLECTIONS] How can you iterate through a Map?
Use entrySet() to iterate through keys and values together, keySet() to iterate through keys, or values() to iterate through values.
[JAVA/COLLECTIONS] What is the difference between HashMap, LinkedHashMap, and TreeMap?
HashMap is the basic map implementation shown. LinkedHashMap retains insertion order, while TreeMap keeps keys sorted.
[JAVA/COLLECTIONS] What does equals() answer?
equals() answers whether two objects are logically equal. Custom objects use the default identity-based behavior unless equals() is overridden.
[JAVA/COLLECTIONS] What does hashCode() answer?
hashCode() determines which hash bucket an object belongs to.
[JAVA/COLLECTIONS] What rule connects equals() and hashCode()?
If equals() is true for two objects, their hash codes should also match. If you override equals(), the slides recommend overriding hashCode() as well.
[JAVA/COLLECTIONS] Why do equals() and hashCode() matter for HashSet and HashMap?
Hash-based collections use hashing to locate objects. If logical equality is customized with equals() but hashCode() is not updated consistently, logically equal objects may be treated as separate entries.
[DESIGN PATTERNS] What are lambda expressions?
Lambda expressions provide compact behavior that can be passed to methods. them with methods such as Iterable.forEach(). Parentheses are required for multiple parameters, curly braces are required for multiple statements, and return can be omitted for a single returned expression.
[DESIGN PATTERNS] Give a simple lambda example.
A simple example from the slides prints every name in a List.
[DESIGN PATTERNS] What is the Stream API?
A Java Stream processes a sequence of data declaratively using a pipeline: Source -> Intermediate Operations -> Terminal Operations.
[DESIGN PATTERNS] What are intermediate Stream operations?
filter(), map(), sorted(), distinct(), limit(), and skip() as intermediate operations.
[DESIGN PATTERNS] What are terminal Stream operations?
forEach(), toList(), collect(), and reduce() as terminal operations, with toList() described as the more modern option than collect() for creating a List.
[DESIGN PATTERNS] What does a basic Stream pipeline look like?
Start from a source such as names.stream(), apply intermediate operations such as filter() or map(), and finish with a terminal operation such as forEach() or toList().
[DESIGN PATTERNS] What is Big O notation?
Big O describes the efficiency and scalability of an algorithm. It describes how execution time or memory usage grows as input size n increases and focuses on growth and worst-case operation counts rather than exact elapsed time.
[DESIGN PATTERNS] What is O(1)?
O(1) is constant time. The runtime does not change as the input grows, such as directly returning array[0].
[DESIGN PATTERNS] What is O(log n)?
O(log n) is logarithmic time. The problem size is repeatedly cut down, such as binary search on a sorted array.
[DESIGN PATTERNS] What is O(n)?
O(n) is linear time. Execution grows proportionally with input size, such as a loop that visits every element once.
[DESIGN PATTERNS] What is O(n^2)?
O(n^2) is quadratic time. Nested loops are a common example; if the data doubles, the work can grow by roughly four times.
[DESIGN PATTERNS] What is the Singleton design pattern?
A Singleton allows one object in memory to be shared across the application. The slides note that frameworks such as Spring can provide singleton instances through dependency injection.
[DESIGN PATTERNS] What is the Factory design pattern?
Factory is used when the program needs to choose which concrete implementation to create at runtime. The slides use payment processors such as Stripe, PayPal, or debit transactions as an example.
[DESIGN PATTERNS] What is the main difference between Singleton and Factory?
Singleton focuses on sharing one instance across the application. Factory focuses on choosing or creating the appropriate concrete object at runtime.
[DESIGN PATTERNS] What is the Observer pattern?
Observer supports a publisher/subscriber style design. The publisher can notify registered observers when its state changes without needing to know the details of each interested observer.
[DESIGN PATTERNS] When is Observer useful?
Use it when the publisher should not need to know exactly who is interested in state changes and the set of interested parties can vary.
[DESIGN PATTERNS] What is the DAO pattern?
The DAO pattern separates data-access code from the rest of the application. The slides summarize the flow as Service -> DAO -> JDBC.
[DESIGN PATTERNS] How is DAO different from Repository in the slides?
DAO emphasizes how the application accesses the database, while Repository emphasizes a collection of domain objects. The slides summarize Repository as Service -> Repo -> JPA/Hibernate.
[JAVA I/O] What are the two broad Java I/O categories shown in the slides?
Streams read and write bytes. Reader/Writer classes read and write characters.
[JAVA I/O] What do FileInputStream and FileOutputStream do?
FileInputStream reads raw bytes from a file. FileOutputStream writes raw bytes to a file.
[JAVA I/O] What do FileReader and FileWriter do?
FileReader reads characters from a file. FileWriter writes characters to a file.
[JAVA I/O] What do BufferedReader and BufferedWriter do?
BufferedReader reads text line by line and is used with a FileReader. BufferedWriter writes text line by line and is used with a FileWriter.
[JAVA I/O] How is Scanner used in I/O?
Scanner can read from an InputStream and provides useful methods for character-oriented input.
[JAVA I/O] What is serialization?
Serialization turns an object in memory into bytes so it can be saved or sent somewhere.
[JAVA I/O] What is deserialization?
Deserialization turns serialized bytes back into an object.
[JDBC] What is JDBC?
JDBC stands for Java Database Connectivity. It is a Java API that lets applications connect to and interact with databases such as PostgreSQL, MySQL, and Microsoft SQL.
[JDBC] What are the four JDBC components listed in the slides?
JDBC API, JDBC Driver Manager, JDBC Test Suite, and the Database Server.
[JDBC] What is the JDBC API?
It is a collection of classes, methods, and interfaces used to communicate with a database, mainly through the java.sql and javax.sql packages.
[JDBC] What does the JDBC DriverManager do?
DriverManager loads or works with database-specific drivers so the Java application can establish a connection to a database.
[JDBC] What is the JDBC Driver interface?
Driver is the base interface for driver classes. Loading a driver class creates an instance and registers it with DriverManager.
[JDBC] What is Statement?
Statement represents a static SQL statement that can be executed to obtain results.
[JDBC] What is PreparedStatement?
PreparedStatement represents a pre-compiled statement that can be executed multiple times. It is created from Connection.prepareStatement() and lets you set values for placeholders.
[JDBC] What is CallableStatement?
CallableStatement is used to execute stored procedures. It can accept input parameters and return one or more results, including output parameters. It is created using Connection.prepareCall().
[JDBC] What is Connection?
Connection represents the connection to a specific database through which SQL statements are executed. It also provides transactional methods such as commit and rollback.
[JDBC] What is ResultSet?
ResultSet represents the table-like result produced by executing SQL statements and provides methods for retrieving and updating its contents.
[JDBC] What is ResultSetMetaData?
ResultSetMetaData provides information about a ResultSet, such as the number of columns, column names, and column data types.
[JDBC] What is the difference between executeQuery(), executeUpdate(), and execute()?
executeQuery() is used for SELECT and returns a ResultSet. executeUpdate() is used for INSERT, UPDATE, or DELETE and returns an int for rows affected. execute() is used when the result type may vary and returns a boolean.
[JDBC] How do you traverse a ResultSet?
The most common approach is to call next() in a loop. next() moves the cursor to the next row and returns true while a valid row exists.
[JDBC] What other ResultSet cursor methods are listed in the slides?
previous() moves backward, first() moves to the first row, last() moves to the last row, absolute(int row) moves to a specific row, relative(int rows) moves forward or backward by an offset, and isFirst()/isLast() test cursor position.
[JDBC] How do input and output parameters work with CallableStatement?
Use set methods for input parameters, registerOutParameter() for output parameters, execute the statement, then retrieve the output with the appropriate get method.
[JDBC] Why use a ConnectionFactory utility class?
The slides use a ConnectionFactory to centralize creation of database connections so the rest of the application can request a connection whenever it needs to execute database commands.
[JDBC] What is java.util.Properties used for in the JDBC example?
Properties is used to read values from a db.properties file so connection values such as the database URL, user, and password are not hard-coded directly into normal application logic.
[JDBC] How does PreparedStatement help prevent SQL injection?
PreparedStatement separates the SQL structure from user-supplied values. The values are treated as data instead of being inserted into the SQL syntax itself.
[JDBC] Why is Statement more vulnerable to SQL injection?
The slides explain that Statement commonly constructs SQL as a complete string before execution, which can allow user input to become part of the SQL syntax.
[JDBC] How do you bind values to a PreparedStatement?
Use setter methods such as setInt(), setString(), and setDouble() with the placeholder index before executing the statement.
[JDBC] What does the RDS JDBC setup slide emphasize?
For PostgreSQL on AWS RDS, the slides show using the RDS connection URL with encrypted traffic and a public certificate bundle. The RDS master user and master password are used as credentials in the example.
[MONGODB] What is MongoDB?
MongoDB is an open-source NoSQL database that stores data in flexible, JSON-like documents instead of traditional rows and tables. The slides describe it as scalable, fast, and adaptable for unstructured or rapidly changing data.
[MONGODB] What is a MongoDB database?
A database is a physical container for collections. A single MongoDB instance can host multiple independent databases.
[MONGODB] What is a MongoDB collection?
A collection is a grouping of MongoDB documents. It is analogous to a table in a relational database, but by default it does not require every document to have the same rigid structure.
[MONGODB] What is a MongoDB document?
A document is the basic unit of MongoDB data. It consists of field-value pairs, is stored in BSON, and is analogous to a row in a relational database.
[MONGODB] What is a MongoDB field?
A field is a key-value pair inside a document. Values can include normal scalar types, arrays, or nested documents. Fields are analogous to columns.
[MONGODB] What is the _id field?
Every document requires a unique _id. It acts like a primary key and defaults to a 12-byte ObjectId when a custom ID is not supplied.
[MONGODB] What does schema-less or dynamic schema mean in MongoDB?
By default, MongoDB does not require you to predefine columns or alter a table definition before new fields are added. Application code can manage document structure dynamically.
[MONGODB] What happens if you insert a new field that other documents do not have?
MongoDB accepts the new field immediately when the collection is using its default dynamic schema.
[MONGODB] What happens when a query looks for a field that a document does not have?
MongoDB does not crash. The document is ignored by the condition or the missing value is treated as missing/null-like depending on the operation.
[MONGODB] How can you add or remove fields during updates?
Use $set to add or change fields and $unset to remove fields.
[MONGODB] Can MongoDB enforce a schema?
Yes. JSON Schema validation that can be applied when a collection is created or added after the collection already exists.
[MONGODB] What do additionalProperties and validationAction do in the validation example?
additionalProperties: false prevents fields outside the defined schema, while validationAction controls what MongoDB does with invalid documents. The slide uses validationAction: "error" to reject invalid documents and notes that "warn" can log warnings.
[MONGODB] What can be specified in a MongoDB JSON Schema validator?
The example uses bsonType, required fields, properties, an email pattern, and numeric minimum/maximum rules.
[MONGODB] How do you create a dynamic collection?
Call createCollection() without a validator. The slides create students, courses, and enrollments this way.
[MONGODB] How do you list collections in a database?
Use getCollectionNames().
[MONGODB] How do you insert one document?
Use insertOne() with a document object.
[MONGODB] How do you insert multiple documents?
Use insertMany() with an array of document objects.
[MONGODB] How can one MongoDB document reference another?
storing another document's _id in a field, such as studentId or courseId in an enrollment document. This is analogous to a foreign-key-style reference.
[MONGODB] What does find() do?
find() queries a collection and can return all matching documents. With no filter, it returns all documents.
[MONGODB] What does findOne() do?
findOne() returns one document matching the supplied filter.
[MONGODB] How can you limit which fields appear in query results?
Pass a projection document as the second argument to find(). including selected fields with 1 and excluding _id with 0.
[MONGODB] How do you count documents?
Use countDocuments().
[MONGODB] What comparison operators are listed in the MongoDB slides?
$gt is greater than, $gte is greater than or equal to, $lt is less than, $lte is less than or equal to, $ne is not equal to, and $in matches any value from a supplied array.
[MONGODB] How does $in work?
$in matches a field against any value in a list. The slides use it to find students whose major is either Computer Science or Mathematics.
[MONGODB] What logical operators are listed in the slides?
$or matches when one condition is true, $and joins conditions with logical AND, and $not inverts a query expression.
[MONGODB] Does MongoDB always require $and for multiple fields?
No. The slides note that MongoDB implicitly uses AND when multiple fields are listed together. $and is especially helpful when applying multiple conditions to the same field.
[MONGODB] What does $exists do?
$exists matches documents based on whether a field is present.
[MONGODB] What does $type do?
$type matches documents where a field has a specified BSON data type, such as string or int.
[MONGODB] How do you query a nested object?
Use dot notation. The slides find students in Boston by querying address.city.
[MONGODB] How do you query whether an array contains a value?
Query the array field directly with the desired value. The slides use enrolledCourses: "CS101".