Concepts Flashcards
Bytecode
An intermediate code between the source code and machine code.
JVM
Java Virtual Machine. It interprets the bytecode into machine code. It is part of the JRE.
JDK
Java Development Kit. It includes JRE, a Java compiler, a debugger, and more;
JRE
Java Runtime Environment; Executes Java programs; It includes JVM and Java libraries.
Declaring a variable
what kind of data it will store
What is a Java class?
a template (blueprint) that is used to create objects. It consists of data members and methods.
Object
objects have states and behaviors.
Eclipse
a Java IDE (Integrated Development Environment). It includes text editor, compiler or interpreter, and debugger, like IntelliJ IDEA
IDE
Integrated Development Environment. for example, visual studio.
How to create a Java object?
Declaration; Instantiation; Initialization
ClassName object = new ClassName()
What are Java constructors?
- A special method that is used to initialize objects
- You would call a constructor when an object is created. It can be used to set initial values for object attributes.
- Note that the constructor name must match the class name and it can’t have a return type (like void)
Pascal case
a naming convention in which the first letter of each word in a compound word is capitalized.
SDK
software development kit
Java variable
a location in memory (storage area) to hold data. Each variable should be given a unique name (identifier)
statically-typed language
It means that all variables must be declared before they can be used.
Java expressions
a construct made up of variables, operators, literals, and method calls.
Java operators
- arithmetic
- assignment
- comparison
- logical
truth table
a mathematical table used to determine if a compound statement is true or false.
component statement
public in Java
an access modifier
- the class is accessible by any other class
- the code is accessible for all classes
default in Java
an access modifier
- the class is only accessible by classes in the same package.
- the code is only accessible in the same package.
private in Java
an access modifier
- the code is only accessible within the declared class.
final in Java
if you don’t want the ability to override existing attributes values, declare attributes as final
static methods/attributes in Java
can be accessed without creating an object of the class first
Java statement
a complete unit of execution
Refactor Code
changing the structure of a program without changing what it does
Side Effect
anything a method does besides computing and returning a value
- any change of instance or class field values
- drawing something on the screen
- writing to a file
- a network connection
Call Site (Method Invocation)
the point of code when the method is called
Operator Precedence
rules that define the order that expressions are evaluated
indexOf() Method
if indexOf doesn’t find the string we’re searching for, it returns -1
string.charAt() Method
Method Overloading
allows you to have multiple methods using the same method name
Value Type
- store values
- value types are copied by value
Reference Type
- store reference
- reference types are copied by reference. We have two references pointing to the same object in the memory.
String Literal Pool
a storage area in Java heap where string literals stored.
Literal
Any constant value which can be assigned to the variable
string1 == string2 vs. string1.equals(string2)
== will test that the variables are referring to the same object, not that they refer to the objects with the same value
== checks the reference equality not the contents
.equals method checks for value equality
StringBuilder Class
allows modifying the strings without creating new string objects
Garbage Collection
to free heap memory by destroying unreachable objects.
Stack vs Heap
The major difference between Stack memory and heap memory is that the stack is used to store the order of method execution and local variables while the heap memory stores the objects and it uses dynamic memory allocation and deallocation.
Mutable Reference Type
a reference to an object that can be changed
return a reference vs. return an object
method chaining for the method that returns an object
single quotes vs. double quotes
Use single quotes for literal chars and double quotes for literal Strings