Java Basics Flashcards
What is Java?
Java is a C-like, multiparadigmed, compiled programming language used for back-end development projects.
What are the advantages of Java? (7 are listed here)
It: 1) is a mature language, 2) is maintained by Oracle, 3) is portable, 4) is platform independent, 5) supports multithreading, 6) is compiled, 7) has automatic garbage collection
What is the JDK?
Java Development Kit. Provides an environment to develop and execute a Java program. Contains the compiler, JRE, and JVM.
What is the JRE?
The Java Runtime Environment. It is all that’s needed to run an application. Contains the core library and JVM.
JVM
Java Virtual Machine. Takes the byte code and executes it. Different operating systems can have different implementations of the JVM.
What is a class?
A class is the blueprint of an object. It defines the states (fields), and behaviors (methods) that its instances may have.
What is an object?
An object is an instance of the class. It is the representation of a real-world entity and has its own implementations of states and behaviors that are defined in its class.
What is the root class from which every class extends.
The object class. Every other class extends the object class and inherits methods from it.
What are some methods from the object class?
Equals(), getClass(), hashCode(), toString()
What are the 8 primitive types in Java?
There is: byte, short, int, long, float, double, boolean, and char.
Where are Strings stored?
Strings are stored in the heap. Strings declared literally are specifically stored in the string pool.
Explain stack vs heap?
Stack is short term storage used for methods currently running while the heap is long term storage used throughout the application.
What is the stack?
Short term storage that holds primitive and reference variables. It follows a LIFO (last in First out) pattern.
What is the heap?
It is long term memory storage. Holds objects and is managed by the garbage collector
What are annotations?
Annotations start with the ‘@’ and are used to provide supplemental information about a program. They can change the way a program is treated by the compiler. They help to associate metadata to the program elements.