Mid Term Study Concepts Flashcards
JDK (Java Developer Kit) is:
-What we use to program Java
-Comes with the compiler(Javac.exe) and the JRE
-The compiler converts source code into byte code
-Source code is the code programmers type into VS code
JRE (Java Runtime Environment) contains:
-Ships with every operating system out there
-Contains the JVM and Java API
JVM (Java Virtual Machine or java.exe) is:
-Converts byte code into machine code
-Exists on many operating systems, allowing java to be cross platform
Java API is:
-A library of java code that we can use
Primitive variables are:
Variables that store values and start with lower case(int, boolean, double, float)
Reference variables are:
-Reference variables store a reference to an object in the heap
-Anytime a object or array is referenced in a method, it is referenced using a reference variable
-String is a reference variable(Reference variables typically start with capital)
Local variable is:
-any variable declared in a method
-stored in the stack frame
Class variables also known as ____ variables, declared with the _____ prefix
Class variables also known as static variables, declared with the static prefix
example: public static int age = 5;
These are static/instance variables from the Class BankAccount:
private static double interest = 4.25;
private double balance = 0;
Why is interest static and balance not, why are they both private?
-Static variables should be values that apply to all objects of a class without being changed, while instance variables can expect to be different from object to object.
-The principle of encapsulation to protect the data means the static and instance variables should be private(inaccessible unless using a getter/accessor).
Arrays are:
An object, so their data is stored in the heap while a reference exists on its stack frame.
Below is an array of objects, explain where in the memory everything is stored:
(Assume student1 and 2 are previously declared)
Student [ ] arr = {student1, student2}
Student [] arr is a reference, with data in the heap. In the heap each of Student [] arr’s indexes store references to the student objects which are also in the heap.
JOptionPane Syntax:
String name = JOptionPane.showInputDialog(“What is your name?”);
System.out.println(“Hello “+name);
How many classes can be made from objects? How about vice versa?
Can’t make classes from objects but the opposite is an infinite amount
What are the four types of access modifiers?
public, private, protected, default
-all these are case sensitive
Static is ___ ______
Static is not OOP.
-all objects would share the same values for their static variables. Instance variables allows for objects to be distinct.