Java 2 Rest of stuff Flashcards

1
Q

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

A

Wrapper classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The ——- method returns the value of the attribute.

The —-method takes a parameter and assigns it to the attribute.

A

Getter
setter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

allows for code that handles multiple data types
It’s another way of achieving polymorphism in java

A

Generics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

writing
providing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

==
.equals() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

———stores primitive types and the addresses of objects.

While ———- stores the value of the object.

A

Stack memory

Heap memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.

A

Garbage collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

———- is the process of converting primitives into their wrapper class variants.

————– (turns a wrapper class into a primitive)

A

Boxing

autounboxing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Contains the code that you want to run that MAY result in an Exception being thrown.

A

Try Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

States the exception type that it can catch, then provides code to run when/if the Exception occurs

A

Catch Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

resource cleanup or if you want any specific thing to happen at the end of the try/catch

A

Finally Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

This is how you make ————. By creating a class that extends Exception or Unchecked Exception and and provide the necessary constructors and methods.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

————– 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.

A

throw
throws

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

——— are both techniques used to improve the performance of software applications by leveraging multiple processors or processor cores.

A

Parallelization and multithreading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

———- 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.

A

multithreading

parallelization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

———— 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.

A

Multithreading
Parallelization

17
Q

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.

A

synchronized method synchronized block

18
Q

The ———- is a powerful tool in Java that allows a programmer to inspect and manipulate the contents of a Java class at runtime.

A

Reflection API

19
Q

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

A

Reflection API