Study Guide Flashcards
What is Compilation
The process a computer takes to convert high level language to machine code
What does it mean for Java to be strongly typed?
Every variable must be declared with a data type
What are primitive types?
Specifies the size and type of variable values and has no additional methods
What are the 8 primitive types in Java
byte
short
int
long
float
double
boolean
char
What is a method?
A collection of statements grouped together to perform an operation
What does ‘return’ do?
Finishes the execution of a method and returns a value
What is a return type?
A data type of the value returned from the method
What does the return type ‘void’ mean?
A method doesn’t return a value or contain a return statement
What is a method parameter?
Values passed into a method to manipulate
What are the different boolean operators?
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
&& Logical and
|| Logical or
! Logical not
What are Strings in Java?
Sequences of characters represented as an instance of the java.lang.String class
What is a Stack Trace?
List of method calls the application was in the middle of when an Exception was thrown
What is the main method?
Starting point for the JVM (Java Virtual Machine) to start execution of a Java program
What is the Syntax of the main method?
public static void main( String args[] ) {
{
What is OOP?
Object Oriented Programming. It organized software design around Data or Objects, rather than functions and logic
What are Objects?
Instances of a class
What makes an Object different from a Primitive Type?
Objects are user-defined, default value is null, kept in a heap, and the reference variable is kept in the stack
Primitive Types are pre-defined, can’t contain null value as the default, and kept in the stack
What is the relationship between a Class and an Object in Java?
Objects are the instances of Classes.
Classes are the “blueprint” for Objects
What are constructors?
Special methods used to initialize Objects
What is the default constructor?
Java compiler automatically creates a no arg constructor if we do not create any constructors
What is an Array?
A collection of similar data elements stored at contiguous memory location. Can be accessed directly by it’s index value
How do I get an element of an Array?
Calling the index number.
String[] fruit = {apple, orange, bananan};
System.out.println(fruit[1]); // gets element “orange”
What are the different flow control statements in Java?
if statements
for loops
while loops
do while loops
switch statements
How is a for loop written in Java?
for(int i = 0; i < 5; i++){
some code
}
What is the difference between ++i and i++
++i pre-increment: we want to increment the value by one then use it
i++ post-increment: we want to use the value then increment it by one
What is the difference between a while loop and a do-while loop?
A do while loop runs through the loop at least once before checking the condition. A while loop must pass the condition before running through the loop
What are break statements?
They are used to terminate the enclosing loop
What are continue statements?
They skip the rest of the loop where it is declared and then executes another iteration of the loop
What is JUnit?
A unit testing framework for Java with the idea of “first testing then coding”
What is a unit test?
Individual units of source code that are tested to determine if they are fit for use
What are some annotations used in JUnit?
@test
@Before
@BeforeClass
@After
@AfterClass
@Ignores
@Test(timeout=500)
@Test(expected=IllegalArgumentException.class)
What is TDD?
Test-Driven Development: A process of relying on software requirements converted to test cases before being developed
What are Exceptions in Java?
Unwanted or unexpected events that occur during the execution of a program
How are Errors different from Exceptions?
Error is used to indicate errors having to do with the runtime environment itself. They indicate a serious problem that a reasonable app should not try to catch.
Exceptions indicate conditions that an application might try to catch.
What is the difference between checked and unchecked Exceptions?
Checked exceptions are checked at compile time by the compiler. You should use the ‘throws’ keyword.
Unchecked exceptions are not checked at compile time and is up to the programmer to specify how to catch these exceptions
What might cause a NullPointerException?
When an application attempts to use an object reference that has a null value
Is ArrayIndexOutOfBoundsException a runtime exception?
Yes, the compiler does not check for this error during compilation
Is FileNotFoundException a runtime exception?
No, it is checked during compilation so it is a checked exception
How do I find where an exception was thrown in a program?
In the exception stacktrace
What does ‘throws’ do?
Indicates what exception type may be thrown by a method
What does try/catch do?
Tries a risky block of code that might cause an exception and catches the exception to continue the program instead of terminating
Can I have multiple catch blocks? Multiple try blocks?
Yes but each try block must be followed by a catch
What are Collections in Java?
Group of individual objects which are represented as a single unit
What is the difference between a List and a Set?
Lists are indexed and allows duplicates
Sets are unordered and can’t have any duplicates
What is the difference between a Set and a Map?
Both don’t allow duplicates and are unordered, however Maps allow any number of null values while Sets can only contain one
What is the difference between a Stack and a Queue?
Stacks are Last In First Out: the elements inserted at the last index is the first element to come out of the list
Queues are First In First Out: elements inserted at the first position are the first to come out
What is the difference between ArrayList and LinkedList?
ArrayLists store only similar data types and LinkedLists can store any type of data
Are Maps part of the Collection Interface?
No since map require key-value pairs
What is a wrapper class?
Class whos Object wraps or contains primitive data types
What do access modifiers do?
Sets access levels for classes, variables, methods, and constructors
What are the 4 access modifiers?
Default: When not explicitly declared, available to any other class in the same package
Private: Access only within the declared class itself
Protected: Can be accessed only by the subclasses in other package or any class within the same package of the protected member
Public: Can be accessed from any other class
What are the non-access modifiers in Java?
Static
Final
Abstract
Synchronized/Volitile
What does Static do?
Creates methods that will exist independently of any instances created for the class
What does Final do?
Can only be explicitly initialized once and variables can’t be reassigned
What is Scope in programming languages?
Defines where methods or variables are accessed in a program
What are the different scopes in Java?
Class Level
Method Level
Block Level
What is SQL and why is it used?
Structured Query Language for accessing and manipulating databases
What are the sublanguages of SQL?
DDL: Data Definition Language
DML: Data Manipulation Language
DRL/DQL: Data Retrieval Language/Query
TCL: Transaction Query Language
DCL: Data Control Language
SCL: Session Control Language
Commands for DDL (Data Definition Language)
Create
Alter
Drop
Truncate
Rename
Commands for DML (Data Manipulation Language)
Insert
Update
Delete
Commands for DRL/DQL (Data Retrieval/Query Language)
SELECT
What is a table in SQL?
A collection of related data held in a database that consists of columns and rows
What are primary keys for?
Uniquely identifies each record in a table
Must be unique and not null
How do I query everything from a table?
SELECT * FROM table
How do I query only the rows that meet some criteria in a table?
SELECT * FROM table WHERE condition
How do I insert into a table?
INSERT INTO table (columns) VALUES (values)
How do I update values in a table?
UPDATE table SET column = value WHERE condition
How do I sort the results of a query in SQL?
SELECT * FROM table ORDER BY column ASC/DESC
What do aggregate functions do in SQL?
Performs a calculation on a set of values and returns a single value
What are some aggregate functions?
COUNT()
MAX()
MIN()
AVG()
ABS()
What is the difference between drop, delete, and truncate?
DROP: Deletes an entire table
DELETE: Deletes specific records from a table
TRUNCATE: Removes all records from a table
What is JDBC?
Java Database Connectivity allows programs to access database management systems
What are the different classes/interfaces used in JDBC?
DriveManager
Driver
Statement
PreparedStatement
CallableStatement
Connection
ResultSet
ResultSetMetaData
What is DAO for?
Data Access Object is a structural pattern that allows us to isolate the application from the persistence layer(database)
What is Mockito for?
Used to mock interfaces so that dummy functionality can be added to a mock interface that can be used in unit testing
How are Mock Objects in Mockito created?
Writing methods to test followed by @TEST with a method for the expected results
What is HTTP?
HyperText Transfer Protocol is a set of rules that describe how info is exchanged and allows the client and server to communicate
What are HTTP Verbs?
Get
Post
Put
Patch
Delete
What is GET usually used for?
Retrieves a list of entities
What is POST usually used for?
Creating an entity
What is PUT usually used for?
Updating an Entity
What is PATCH usually used for?
Partially updating an entity
What is DELETE usually used for?
Deleting an entity
What are 100-level status codes for?
Informational response
What are 200-level status codes for?
Successful Requests
What are 300-level status codes for?
Redirection, further action needed to be taken to complete the request
What are 400-level status codes for?
Client side error, request contains a bad syntax
What are 500-level status codes for?
Server side error, Server failed to fulfill a bad request
What is a path parameter?
Request parameters attached to a URL to point to a specific rest API resource. Appear before the question mark in the URL
What is a query parameter?
Optional key-value pairs that appear after the question mark in the URL
What is a request body?
Data transmitted to an HTTP transaction immediately following the headers
What is a response body?
Data transmitted to an HTTP transaction
What are headers?
They let the client and server pass additional info with an HTTP request. Consists of case-insensitive name followed by : then it’s value
What is JSON?
File format and data interchange format that uses human readable text to store and transmit data. Uses key-value pairs
What is Javalin?
A lightweight REST API library
How can I design an endpoint in Javalin?
app.get(“/url”, this::methodnamehandler);
What is the Context object used for in Javalin?
Allows you to handle an http-request
Can you explain the 3-layer controller-service-DAO architecture?
Controller: handles the navigation between different views
Service: Stands on top of the persistence mechanissm to handle users requirements
DAO: Encapsulates the details from the persistence layer and provides a crud interface for a single entity
What is Maven?
Build automation tool that adds new dependencies for building and managing projects
What file should be changed to add new Maven dependencies?
pom.xml
What is the Maven lifecycle?
validate
compile
test
package
integration test
verify
install
deploy
How do I find and add a new dependency to Maven?
mvn install -
What are foreign keys in SQL?
A field in one table that refers to the primary key in another table
What is the referential integrity in SQL?
Refers to the relationship between tables. It’s the logical dependency of a foreign key on a primary key
What is a constraint in SQL?
Rules enforced on the data columns of a table
What is the NOT NULL constraint?
The value must be filled into that field…Can’t be left blank
What is the UNIQUE constraint?
Makes sure the column’s value is unique in the table…No duplicate values
What does GROUP BY do?
Groups rows that have the same values into summary rows
What does HAVING do?
Used to filter the results of a GROUP BY query based on aggregate calculations
What is an alias in SQL?
Temporarily renaming a table or column for easier reading
What is multiplicity in SQL?
Specifies the number of instances of a type of data in a table?
What the different types of multiplicity?
one to many
zero or one to one
zero or one to many
What do you need to add to have one to many multiplicity?
an entity instance can be related to multiple instances of the other entities
What do you need to add to have many to many multiplicity?
Entity instances can be related to multiple instances of eachother
How do you modify existing tables?
ALTER TABLE table
What is normalization and why do we use it?
Process of taking a database design and apply a set of formal criteria and rules called normal forms. It reduces redundant data
What characterizes 1st normal form (1nf)?
Rows/columns not ordered
No duplicate data
Row/column intersection have unique and no hidden values
What characterizes 2nd normal form(2nf)?
Fullfil 1nf requirements
All nonkey columns must depend on primary key
Partial dependencies are removed and placed in a separate table
What characterizes 3rd normal form(3nf)?
Fullfils 2nf requirements
Non primary key columns shouldn’t depend on other non primary key columns
No transitive functional dependency
What is a join in SQL?
Combines records from two or more tables in a database
What is an inner join?
Returns matching rows from both tables
What are left/right joins?
Returns all rows from specified side and matching rows from the other side
What is a view in SQL?
Virtual tables from tables in a database
What is REST?
REpresentational State Transfer making computer systems on the web communicate with each other easier
Why do we use REST?
They are stateless and they separate the concerns of the client and server
What is a resource in REST?
Entities that are accessed by the URL you supply
What does it mean to be stateless?
Each request must contain all the information necessary to be understood by the server instead of being depending on the server remembering prior requets
What do we need to do to make an endpoint RESTful?
The client request should contain all the information necessary to respond
What is the JDK?
Java Development Kit that offers tools necessary to develop Java programs
What is the JRE?
Java Runtime Environment provides the minimum requirements for executing Java applications. It consists of the JVM, core classes, and supporting files
What is the JVM?
Java Virtual Machine that is responsible for executing code line by line
What terminal command is used to compile a Java File?
JAVAC
What is contained in Stack Memory?
Temporary memory allocation for variables
What is contained in Heap Memory?
Long term dynamic memory. Chunk of memory available for the programmer
What is the String Pool and does it belong to Stack or Heap Memory?
When creating a string it looks for a reference to that string in the pool and assigns it. It is contained in Heap Memory.
What is garbage collection?
Process by which java programs perform automatic memory management
What is UNIX?
Operating system developed in the 1960s which has been under constant development since
How do i change directories in UNIX?
cd directoryname
How do I view contents of my directory in UNIX?
ls
What is Git?
Distributed version control system that tracks changes in any set of computer files
Why do we use Git?
Coordinating work among programmers and seeing changes made throughout applications
What is a commit?
After making changes in code you commit and set a message stating what changes were made. It saves a revision of the code to be pushed
What is GitHub?
Website to push changes to code for storing and viewing
What does pushing do?
Sends the commited code to some other source
What does pulling do?
Retrieves previously pushed code to you local machine
What does clone do?
Downloads a project form a source to your local machine
What does branch do?
Creates a new branch of the main code base to work on different features of an application without affecting the main code
What does checkout do?
Switches branches
What does merge do?
Joins two or more development histories together
What is a merge conflict?
When two or more developers change the same line or code or deletes a file one was working on and git can’t automatically determine which is correct
What are the 4 pillars of OOP?
Abstraction
Encapsulation
Inheritance
Polymorphism
What is Inheritance?
Subclasses extend the base class and takes on their properties and methods
What is Polymorphism?
Methods with the same name taking on different forms and functions. Can be done by overriding or overloading
What is Encapsulation?
Information hiding from the user and making the class attributes inaccessible from the outside classes. Use getters and setters to obtain info
What is Abstraction?
Handles complexity by hiding unnecessary details from the user so they only focus on the applications main function
What is the Object class in Java?
It is the Parent class of all classes in Java
What methods does the Object class contain?
getClass()
hashCode()
wait()
toString()
clone()
equals()
finalize()
notify()
notifyAll()
What are Generics in Java?
It means parametrized types allows all types to be a parameter to methods, classes, and interfaces
What are interfaces in Java?
Abstract class that is used to group related methods with empty bodies. Uses implements instead of extends. It’s an Is-A Relationship
What does extending a class do?
Allows the sub classes to inherit to methods and properties of the base class
What does implementing an interface do?
Achieves total abstraction and allows us to achieve multiple inheritance of a class since you can’t extend multiple classes
What is the difference between runtime and compile time polymorphism?
Runtime: Dynamic, Overrides methods: A method with the same name is extended/implemented overrides the base method
Compile time: Static, Overloads methods: Multiple methods with the same name but different amounts or types of parameters
What is Method Overloading?
Multiple methods with the same name but different types or amount of parameter values
What is Method Overriding?
A method with the same name in a child class overrides the parent class method of the same name
Can you extend multiple classes?
NO
Can you implement multiple interfaces?
YES
How might access modifiers help us achieve Encapsulation?
Having private or protected modifiers keeps data contain to the class itself
What does the Comparable interface do?
Used to compare an object of the same class with an instance of that class
What is the SDLC?
Software Development Life Cycle is a framework that development teams use to create a cost effective and time efficient piece of software. Agile is an example.
What is Agile Development?
An approach to the software development life cycle that supports collaboration, flexibility, and iterative development. Focuses on user experience and input given to developers.
What is a Sprint?
Set periods of time that team members have to complete their tasks and review what they’ve been working on.
What are Ceremonies in Agile/Scrum
Meetings where the development team comes together to keep each other updated on their assigned tasks for projects.
What are User Stories?
Features that the end user would like to see implemented in the project.
What is Story Pointing?
A value assigned to user stories to help determine how much effort is needed to complete a feature.
What is Velocity in Agile Development?
A way to measure the time it takes for the development team to implement user stories within a sprint. It assists the project manager in getting a realistic idea of how much progress is being made at the end of each sprint.
What is Time Complexity?
An estimate of how long an algorithm will take to execute on different input sizes
What is O(1)?
O(1) is Constant time: The algorithm will take the same amount of time regardless of input size
What is O(n)?
O(n) is Linear time: Execution time scales directly with input size. (For-Loops)
What is O(log n)?
O(log n) is Logarithmic time: Each time the size of the input doubles, the execution time increases by the same amount. (Binary search)
What is O(n^2)?
O(n^2) is Quadratic time: The algorithm scales by the input sizes’ square.(Nested For-Loops)
Describe the Linear Search Algorithm and what is the Time Complexity?
Linear search algorithms start at the beginning of list of elements and iterates each one until it finds the target element. An example would be iterating through an array with a for loop.
Time complexity is O(n): Linear time
Describe the Binary Search Algorithm and what is the Time Complexity?
Binary search algorithms start at the middle of a list of elements. If the target element is the middle element the algorithm completes.
If the target element is larger than the middle element, it searches to the right of the middle element and repeats the process again until the target is found.
If the target element is smaller than the middle element, it searches to the left of the middle element and repeats the process again until the target is found.
Time complexity is O(log n): Logarithmic time
What is one way you could take to sort an Array?
There are several different algorithms to sort arrays. The simplest and most efficient is the Selection Sort:
First iteration compares each value to find the smallest value in the array and swap it with the element at index 0.
The next iteration would would find the smallest value again but would start at the next index value.
Repeats until Array is sorted.
Time complexity of O(n^2) Quadratic time because it utilizes nested for-loops.
How does ArrayList work?
ArrayLists work similar to Arrays where you access elements by the index value, however they can change size has many methods to add elements (add()), modify elements (set()), and delete elements (clear()).
How does a LinkedList work?
LinkedLists element’s are called Nodes. LinkedLists aren’t stored in a contiguous manner in memory. Each node as a pointer to the next node which is how each node finds the next in memory.
Singly LinkedLists only works forward. The first Node only stores the memory location of the next Node.
Doubly LinkedLists can traverse forwards and backwards as each node stores the memory location of the previous and the next Node.
What is a Thread?
In Java, a thread is the smallest unit of processing that can be executed independently by the JVM. It is essentially a lightweight sub-process that runs concurrently with other threads within a program.
Why would using threading be advantageous?
Can improve the performance of a program by allowing multiple threads to execute in parallel
Can make the program more responsive by allowing it to continue to process user input while performing other tasks in the background
Improves efficiency of time and utilization of resources because processes can run asynchronously and concurrently
How do you create a new thread?
A thread is created by extending the java.lang.Thread class or implementing a runnable interface.
Get an ExecutorService instance with Executors.newFixedThreadPool(int)
Create a new WaitingThread with a new WaitingThread(String, int)
What is a race condition?
A race condition occurs when more than one sub-processes attempt to access the same location in memory at which a particular object is stored.
How would you prevent a race condition?
Race conditions can be prevented by synchronizing the sub-process/method
Synchronization may be implemented by:
1: Using the synchronize keyword
2. Using Mutexes
3. Using Semaphores
4. Using a Lock
Alternatively using thread safe data structures, proper encapsulation of data within a sub-process, messaging between threads, and atomic operations can prevent race conditions
What is a Deadlock?
When multiple threads are attempting to access the same resource so neither actually can access it.
What features were added to Java 5?
Generics
Enhanced For-Loops
Autoboxing/Unboxing
Typesafe enums
Varargs
Static import
Concurrent collections
Copy on write
compare and swap
Locks
What features were added in Java 8?
Lambda Expressions
Streams
Nashorn
String.join()
What is Reflection?
Java feature that allows a program to examine or “introspect” upon itself, and manipulate internal properties of the program. (getClass())
What is a Lambda Expression?
Short block of code which takes in parameters and returns a value.
Similar to methods but don’t need a name and can be implemented in the body of a method
What is a Functional Interface?
Interface with only one method (ex…Single Abstract Method)
What are Streams?
Abstraction of non-mutable collection of functions applied in some order to the data. They do not store data.
What are some operations that streams can do?
Intermediate Operations (Returns another stream) or Terminal Operations (triggers the execution of the stream pipeline)
ForEach(): Terminal operation, loops over the stream elements
Map(): Produces a new stream after applying a function to each element of the original stream
Collect(): Gets elements out of the stream into and puts the values into the variable
Filter(): produces a new stream with elements that pass the predicate
Findfirst(): returns an optional for the first entry in the stream
ToArray(): returns an array of elements from the stream
FlatMap(): Helps “flatten” data structure to simplify further operations
Peek(): Allows the developer to perform multiple operations on each element in a stream
How does the Singleton Design Pattern work and why would you use it?
A creational design pattern that ensures that a class has only one instance, while providing a global access point to this instance. We use it because it is more memory space efficient and the single object can be used repeatedly over the client program.
How does the Factory Design Pattern work and why would we use it?
A creational design pattern used to create an object without exposing the creation logic to the client. We use it to provide an approach for interface rather than implementation and provides abstraction.
What is Logging?
A framework for Java to understand and debug program runtime behavior by capturing persisting important data, making it available for analysis at any point in time.
Why would you use Logging?
It eases and standardizes the debugging process by providing flexibility and avoiding explicit instructions
What is Procedure in PL/SQL?
Functions that will auto trigger when something happens. Procedures will hide the SQL queries to improve performance by having less information sent to the database
What is a Trigger in PL/SQL?
When an event occurs and stored in the database and it’s consistently called upon.
In SQL what is an Index?
A table to quickly look up information from other tables that need to be searched frequently
What is an SQL Index Advantageious?
It performs repetitive queries faster by storing the information into a table.
What is the general structure of an HTML document and what are the different parts of the documents used for?
HTML documents are divided into 2 parts:
head:
Contains <title> tag to give the webpage a title and to be visible on the web browser as well as <style> or
tags to incorporate other files</style></title>
body:
Where we design the structure of the webpage
What are some HTML elements?
<title>
<head>
<div>
<p>
<h1>-<h6>
<ul><ol><li>
<img></img>
<a>
and more...
</a></li></ol></ul></h6></h1></p></div></head></title>
What are inline and block elements?
Inline Elements: Do not start a new line and take up the width of the content
Block Elements: Start a new line and take a full width of the available space.
We can have inline elements inside block elements but can’t have block elements inside inline elements
What is the purpose of assigning ID’s and Classes to elements?
Assigning Id’s to an element allows for styling or manipulation of a single element
Assigning Classes to elements allows for styling or manipulation of a group of elements sharing the same class
How do you create an ordered list or an ordered list?
Ordered List: <ol></ol>
Unordered List: <ul></ul>
What new features were introduced to HTML5?
Video and Audio Features
Header and Footer Tags
Input Tags
Figure and Figcaption
Regular Expressions
Increased Adaptability for accessibility
Cryptographic Nonces
How can you attach Javascript to an HTML File?
<script> content here </script>
or
What is CSS?
Cascading Style Sheets are a mechanism for adding style such as fonts, colors, backgrounds to HTML files
What are three different ways to apply CSS to HTML elements. Which one takes priority?
Inline: Takes priority” use the style attribute inside the HTML elements
Internal: using <style> tag within the <head> section</style>
External: Using <link></link> in the HTML file and sourcing it to an external CSS file.
What is the CSS box model?
A box that wraps around every HTML element that consists of margins, borders, padding, and the actual content
What is responsive web design?
Web places that look good on all devices. A responsive web design will automatically adjust for different screen sizes and viewports
What is JavaScript?
A light weight and interpreted programming language with Object Oriented capabilities. Allows for client side script to interact and make dynamic changes to web pages.
Runs on a single thread with an event loop handling events.
What does it mean for JavaScript to be loosely typed?
Variables don’t necessarily need a variable typing when declared. JS automatically types a variable based on what kind of information you assign to it.
What does it mean for JavaScript to be interpreted?
JS does not need to be compiled to be run. It is immediately run by the browser without any conversion into another language.
What are the 8 types in JavaScript
undefined
null
boolean
number
bigint
string
symbol
object
What is type coercion in JavaScript?
The automatic or implicit conversion of values from one data type to another (such as strings to numbers)
What are truthy and falsy values in JavaScript?
Values that are considered true/false when encountered in Boolean context. All values are truthy unless they are defined as falsy
Examples of falsy values:
false
0
-0
“”
null
undefined
NaN
What is the difference between == and === in javascript?
== does type conversion and compares the values (5 == “5”) is true
=== does strict type conversion and compares values and data type (5===”5”) is false
What are the different ways to declare a variable in Javascript?
Let: block scoped
const: block scoped and can’t be reassigned
var: global scope - hoisted to the top of the file
What are callback functions in Javascript?
A function passed to another function as an argument because functions can be used as variables in JS.
What is the DOM?
Document Object Model is the representation of the HTML document in memory. It is generated and can be manipulated by web API’s to change the look of the page as its being viewed.
How can I select and modify HTML elements in Javascript?
document.getElementById()
document.getElementByClassName()
document.querySelector()
document.querySelectorAll()
How can I have Javascript execute some function when a button is clicked?
Adding event listeners such as button.onclick() or button.addEventListener(“click”, function())
What is an EventListener and why is it used?
A built in function in Javascript that allows us to wait for user interaction and then run some code. Usually used on buttons, inputs, or when users type or clicks on the screen
What is bubbling and capturing?
Bubbling happens when an element received an event and that event is propagated to its parent and ancestor elements in the DOM
Capturing is when the event is first captured by the outermost element then propagates to the inner elements.
What is the event loop in Javascript?
Responsible for executing the code, collecting and processing events, and executing queued sub tasks
What are Promises and what are they used for?
The object that represents the eventual completion or failure of an asynchronous process and its result. Stores a value and “promises” to use that data later.
What do Async and Await do in Javascript?
Async are tags you can use on methods and processes inside methods to enable promise based behavior.
await makes javascript wait until the promise is settles and returns the result.
What are features introduced in javascript version ES6?
Const
Let
Arrow functions
Template Literals
Default Parameters
Object and Array Destructing
Classes
Rest Parameter
Spread Operator
What are arrow functions?
A more concise way for writing functions
hello = () => return “hello world”
What are template literals?
A form of making strings that allow creating multiple line strings more easily and uses place holders to embed variables in a string. Encase your string in backticks and interpolate your variables with ${}
What is a closure in Javascript?
Makes it possible for a function to have “private” variables. It allows a function to have access to the parent scope, even after the parent function has closed
What is the fetch API?
A promise-based interface for fetching resources by making HTTP requests to servers from the web browsers. We can use the FETCH() method, it will allow us to fetch data from different places and work with the fetched data.
What is Node.js and why do we use it? How is it different from out previous way of running Javascript?
Node.js is a server side way of running Javascript code, it allows us to use JS on both front and backends. Without Node, JS is run only on a client’s web browser
What is NPM?
A dependency management tool that allows us to easily install the packages needed to run a program with Node.js. It stands for Node Package Manager.
What is the package.json file?
It lists all of the dependencies and their versions that are needed to develop and run JS projects. It is used by NPM
What is Typescript and why do we use it?
It is a superset of Javascript and adds types to Javascript. By allowing types, TS helps to identify errors in the code at compile time. It uses compile time checking
What is transpilation? What command is used to transpile Typescript?
It is compiling Typescript to Javascript and its various versions.
The command is npx tsc
What types does Typescipt introduce that Javascript does not have?
Typescript is a syntactic superset of Javascript which adds static typing. It adds syntax on top of Javascript which allows developers to add types
What features does Typescript introduce other than strong typing?
Allows for stronger OOP through the introduction of interfaces and access modifiers
Support classes and other OOP concepts
Provides interface, which allow you to define contracts that describe the expected shape of the object
Decorators: TS equivalent of annotations in Java
Why would we use interfaces in Typescript?
Allows users to define their own objects.
The compiler uses interfaces for Type checking to check if the object has a specific structure or not. (duck typing or structural subtyping)
What is a decorator?
A function that we use to attach metadata to a class declaration, method, accessor, property, or parameter. Such as @Component, @Input, @Output
What is a component in Angular?
A building block used to create out application, which allows to break down an application into smaller and reusable parts. Easier to maintain and update.
What files does a component contain?
component.css
component.html
component.spec.ts
component.ts
What is a service in Angular and what is special about them?
A class that is used for fetching data from the server, validating user input, or logging directly to the console. Containing logic that we would like to separate from component specific logic
Can be injected into a class to helps maintain their singleton model thus they are marked with the @Injectable annotation.
What is a module in Angular?
A mechanism to group component, directives, pipes, and services that are related, in such a way that can be combined with other modules to create an application
Each Angular application has to have a root module @NgModule
How do you set up a new Angular app using the Angular CLI?
npm install -g @angular/cli
cd folder_path
ng new project_name
How do you generate a new angular component using the Angular CLI?
ng g c component_name
What is a Single Page Application and what are the benefits/downsides of using an SPA?
A web design pattern where instead of navigation links going to separate pages, the routes will change the components that are displaced on a single page.
Components are loaded up front so navigation on a website is faster. However the first time the page loads it will take much longer.
What is routing? How do you create a new route?
A way to change what is displayed on an SPA to simulate page navigation.
{ path: ‘home’, component: HomeComponent }
What is a route guard?
Determines if a user can access a route, for example a user must log in to see their account details
What does it mean for components to be eagerly loaded?
The component is loaded into cache when the page is first accessed instead of when the component is to be displayed on the page
What are lifecycle hooks in Angular?
Methods in Angular to tap into different phases of a components life. They allow you to perform actions at specific points during the components lifecycle, such as initialization, change detection, and cleanup
When does ngOnInit run?
After angular has initialized all data bound properties for additional initialization
When does ngOnChange run?
When angular sets or resets data bound input properties
When does ngOnDestroy run?
Just before angular destroys a component or directive for cleanup to avoid memory leaks
What is property binding, and its syntax?
A one way data binding technique in Angular used to bind DOM element property to a component’s property. This allows the components property to be reflected in the DOM
[property]=”expression”
What is event binding and its syntax?
One way data binding technique used to bind a DOM elements even to a method in the component. Allows the component to respond to user interactions or events
(event)=”methodName()”
What is 2-way data binding and its syntax?
A combination of property binding and event binding, allowing the components to update the DOM property, and the DOM’s property to update the components property. This enables a seamless synchronization between the component and the view.
[(ngModel)]=”property”
What are event emitters for?
Used to emit custom events from a child component to a parent component. They are usually implemented using the EventEmitter class. It enables a child component to communicate with its parent component by emitting events and sending data
What is interpolation and its syntax?
A special syntax that Angular converts into property binding. It is used for one way data binding and displays a component property in the respective view template. It is an alternative to property binding and can be used to display strings, numbers, dates, arrays, lists or maps.
<h3>Current customer: {{ currentCustomer }}</h3>
What do structural directives do in Angular?
Responsible for manipulating the DOM structure by adding, removing, or modifying elements. They usually change the layout of the structure of the view based on some condition
What does ngIf do?
Used to conditionally render a part of the DOM based on a given expression. If the expression evaluates to true, the element and its content are added to the DOM and vice versa
What does ngFor do?
Used for rendering a list of items. It iterates over a collection of elements like an array, and creates a DOM element for each item in the collection.
What do attribute directives do in Angular?
Used to change the appearance or behavior of a DOM element, component, or another directive. They’re applied as attributes to elements in the template and can manipulate the properties of those elements
What are pipes used for?
Used to transform data before displaying it in the view.
Can you describe the pub/sub design?
The publish/subscribe design is a pattern used in applications to send requests for data by a subscriber who receives data from a publisher
What are observables?
Objects used in the RxJ (Reactive Extensions for Javascript) library to handle asynchronous data streaming
How do you use the HTTPClient?
Handles data input from users and sends them as requests to a backend server.
Implemented by:
importing the module
Importing the module in the “ngModule” imports array`
How do you pass data from a parent component to a child component in Angular?
Prepare a property in the child component using the @Input() annotation
Bind a property that exists in the parent to the child component property
How do you pass data from a child component to a parent component in Angular?
Prepare the parent component to recieve data using the @Output() decorator
Bind an event to the child component that emits data using an EventEmitter
How would you maintain some variable globally across an Angular app?
Export a constant
What is Spring?
A Java platform that provides infrastructure support to develop Java applications. Developers can focus on the application itself while Spring manages the infrastructure.
What are some Spring modules?
The core container: Consists of the Bean
The ORM Module (JPA) for data access
The Web-Servlet modules which provides Spring’s MVC implementation for web applications
What is a Bean?
Objects managed by Spring that live in Spring’s application context and can be injected into an existing class.
What is Dependency Injection?
Injecting objects into other objects. Used to connect a class with its dependencies. Methods to inject dependencies are Constructor Injection and Setter Injection
What is the Spring IOC Container?
Inversion of Control is the transfer of control of objects or portions of a program to a container or framework.
What is the difference between the BeanFactory and ApplicationContext?
BeanFactory provides the configuration framework and the basic functionality. It is a parent interface of ApplicationContext
ApplicationContext adds additional functionality like easy integration with Spring AOP features, message resource handling event propogation, and contexts specific to the application layer like WebApplicationContext.
ApplicationContext extends BeanFactory and loads the beans eagerly on startup.
What does the @Bean annotation do?
A method level annotation and a direct analogue of the XML element. It marks a factory method which instantiates a Spring bean.
What does the @Component annotation do?
The main Stereotype Annotation. It is a class level annotation and used across the application to mark the beans as Spring’s managed components
What does the @Autowired annotation do?
Used for dependency injection. We can use this annotation with a constructor, setter, or field injection. Places an instance of one bean into the desired field in an instance of another bean.
What are different ways to perform dependcy injection using Autowiring? (Places to put the autowired annotation)
Field Injection
Constructor Injection
Setter Injection