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