Udemy_Java

Ace your homework & exams now with Quizwiz!

Every library goes in what three things (GAV)

-Group ID (make own package unique to entire world) -Artifact ID (project name and version) -Version (

static variable

-a class-level variable that is shared among all instances of a class. -It is declared with the static keyword, which means that it belongs to the class rather than to any specific object

TypeConversion and Casting

Casting - process of explicitly converting a variable from one data type to another Type Conversion - process of converting a value from one data type to another

Editor vs IDE

Editor: only type the code IDE: type the code, run the code, debug the code, compile the code, etc

what does IDE stand for

Integrated Development Environment

JDK(java development kit) vs JRE(java runtime environment) vs JVM(java virtual machine)

JDK-software development used to develop java applications (javac, jshell, etc) JRE-the runtime environment needed to run java applications. includes the JVM and core libraries but no compiler JVM-the component that executes Java bytecode, which is the intermediate representation of Java code after it has been compiled. interpreting bytecode into machine code that can be executed by underlying operating system

what creates objects in java

JVM -JVM job to get the object while coder gives blueprint (class) -class file gets compiled to create a byte code -byte code goes to JVM, JVM creates object

what term is used when we can define two or more methods of the same name within the same class

Method overloading

java --version

java to run the applciation

javac --versoin

javac to compile the code

what will happen if a local variable has the same name as an instance variable within a class

local variable hides the instance variable

what does LTS stand for

long term support

what does POM stand for

project object model -where you do everything to handle your maven -

what is Java

-developed by Sun microsystems, now acquired by Oracle -platform independent (meaning that code written in Java can run on any device or OS that supports JVM -multithreaded -comes with a vast standard library (Java API) -auto manages memory allocation and deallocation through its garbage collection, -(JIT) just in time compilation -object oriented(everything should be an object in java)

Literals

-fixed values that are directly written into code -values represent constant data and not variables -values don't change -used to assign values to variables or constants in java

instance variables

-inside a class, outside any method/constructor/block -accessible by all methods in the class through the object -exists as long as the object exists -gets default values if not initialized -stored in the heap (part of the object) -can have access modifiers

local variables

-inside a method -accessible only within the method/block where declared -exists only during the method/block execution -must be initialized before use -stored in the stack -cannot have access modifiers

Jshell

-introduced in java 9 -allows you to run Java code snippets quickly without the need to compile and run a full Java program. -test such as expressions, statements, and method declarations, without needing to wrap them in a class or method. -You can quickly test out different Java APIs and understand how they work without setting up a full project. -You can also write a series of commands in a file and execute them with jshell as a script. -just a parse statement

static method

-method that belongs to class -no access to instance methods or instance variables -used as utility/helper methods -main method is static is because needs to be invoked by java runtime without creating an instance of class

Object

-object is a fundamental entity that represents a real-world entity or a concept. -Objects are instances of classes, which are blueprints that define the properties (attributes) and behaviors (methods) that the objects created from them can have. -every object knows something and does something

project management tool

-software or platform designed to help individuals and teams, plan, execute, and monitor process of projects.

stack memory

-stores local variables, method calls, and references to objects -follows LIFO order and is auto managed by the JVM -has a fixed size easier to access -variables in stack are auto removed when method call -

heap memory

-stores objects and their instance variables -managed by the JVM's garbage collector -larger and more flexible in size, but slower to access -objects remain in the heap as long as they are referenced by any part of the program

JAR file

-used to aggregate multiple java class files with associated metadata and resources (such as text, images, etc) into a single file for distribution -JAR files are built on the ZIP file formate and have the .jar file extension

StringBuffer vs StringBuilder

String Buffer is thread safe, and String Builder is not

static block

a block of code that is executed when the class is first loaded into memory. It is used to initialize static variables or perform operations that need to be executed only once, at the time of class loading.

explain how java works

step 1-programmer write java code (.java extension) step 2- java code with .java extension gets compiled by compiler(javac) step 3- after code is compiled we get a bytecode that has .class file step 4- run the .class file in JVM step 5- JVM is apart of JRE which will have JVM as well as a libraries, a lot of classes step 6-everything is apart of JRE you install on OS step 7- developers use JDK (provides updated JRE and JVM with it)

how to create an object

use the 'new' keyword

Primitive Casting

widening casting(Auto): converting a smaller type to a larger type size byte -> short -> int -> long -> float -> double Narrowing Casting(Manual) : converting a larger type to a smaller size type double -> float -> long -> int -> short -> byte


Related study sets

Chapter 7 Computers in HIM Part #1

View Set