Java 2 Rest of stuff Flashcards
treat primitives as objects. More specifically, they are the Class versions of your primitive types
This is necessary for when you NEED to use objects, and primitives aren’t allowed ie… collections
Wrapper classes
The ——- method returns the value of the attribute.
The —-method takes a parameter and assigns it to the attribute.
Getter
setter
allows for code that handles multiple data types
It’s another way of achieving polymorphism in java
Generics
Generics Take two forms in the code
One when ——— code that will provided a type value
And a different form when actually —–the value
Generics only work with reference ( one of the major reasons for the invention of the wrapper classes
writing
providing
The —– operator can be used for comparing references (addresses) and checks if the objects point to the same memory location
while the ———can be used to compare the content and it also compares the values of the objects.
==
.equals() method
———stores primitive types and the addresses of objects.
While ———- stores the value of the object.
Stack memory
Heap memory
the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.
Garbage collection
———- is the process of converting primitives into their wrapper class variants.
————– (turns a wrapper class into a primitive)
Boxing
autounboxing
Contains the code that you want to run that MAY result in an Exception being thrown.
Try Block
States the exception type that it can catch, then provides code to run when/if the Exception occurs
Catch Block
resource cleanup or if you want any specific thing to happen at the end of the try/catch
Finally Block
This is how you make ————. By creating a class that extends Exception or Unchecked Exception and and provide the necessary constructors and methods.
————– is used to explicitly throw an exception from a method or a block of code.
———- is used in a method declaration to indicate that the method might throw one or more exceptions.
throw
throws
——— are both techniques used to improve the performance of software applications by leveraging multiple processors or processor cores.
Parallelization and multithreading
———- involves concurrent execution of multiple threads within a single process, while
involves executing multiple processes or threads in parallel across multiple processors or processor cores.
multithreading
parallelization
———— is like a person who can do multiple things at once, like cooking, cleaning and watching TV all at the same time.
is like having multiple people working on the same task, like a group of friends who work together to build a big sandcastle at the beach. Both techniques help get things done faster, but they work in different ways and are better suited for different types of tasks.
Multithreading
Parallelization
A ——— is a method that has the “synchronized” keyword in its method signature. When a thread enters a synchronized method, it acquires a lock on the object that the method is called on. Other threads must wait until the lock is released before they can execute the method.
A ———— is a block of code that is wrapped in the “synchronized” keyword and takes an object reference as an argument. When a thread enters a synchronized block, it acquires a lock on the object that is passed as an argument.
synchronized method synchronized block
The ———- is a powerful tool in Java that allows a programmer to inspect and manipulate the contents of a Java class at runtime.
Reflection API
Benefits and drawbacks of —-:
benefits
Flexibility:
Reduced code duplication:
Frameworks and libraries:
drawbacks
Performance: The Reflection API can be slow
Security: Reflection can be a security risk
Compatibility: The use of the Reflection API
Reflection API