Java Advanced Flashcards

(83 cards)

1
Q

Define Java Virtual Machine (JVM).

A

An abstract computing machine that enables Java bytecode execution.

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

What is Garbage Collection in Java?

A

Automatic memory management that reclaims memory used by objects no longer needed.

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

True or false: JIT compilation improves performance by compiling bytecode to native code.

A

TRUE

JIT stands for Just-In-Time compilation, optimizing runtime performance.

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

Fill in the blank: Java’s main method signature is _______.

A

public static void main(String[] args)

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

What does JNI stand for?

A

Java Native Interface, allowing Java code to call native applications.

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

Define multithreading in Java.

A

The concurrent execution of two or more threads for improved performance.

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

What is the purpose of synchronized keyword?

A

To control access to a block of code or object by multiple threads.

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

True or false: Java supports operator overloading.

A

FALSE

Java does not allow operator overloading to maintain simplicity.

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

What is a Java package?

A

A namespace that organizes a set of related classes and interfaces.

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

Fill in the blank: Exception handling in Java uses _______ and _______.

A

try, catch

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

Define Java Stream API.

A

A feature for processing sequences of elements using functional-style operations.

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

What is Lambda expression?

A

A concise way to represent an anonymous function in Java.

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

True or false: Java is platform-dependent.

A

FALSE

Java is platform-independent due to the JVM.

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

What is a Java Interface?

A

A reference type that can contain only constants, method signatures, and nested types.

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

Fill in the blank: Polymorphism allows methods to do _______ based on the object.

A

different things

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

Define Java Collections Framework.

A

A unified architecture for representing and manipulating collections of objects.

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

What is a HashMap?

A

A collection that maps keys to values, allowing null values and one null key.

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

True or false: ArrayList is synchronized.

A

FALSE

ArrayList is not synchronized; use Collections.synchronizedList for thread safety.

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

What is Java Reflection?

A

A feature that allows inspection and manipulation of classes, methods, and fields at runtime.

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

Fill in the blank: Java Annotations provide _______ about a program but are not part of the program itself.

A

metadata

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

Define Java Enums.

A

A special Java type used to define collections of constants.

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

What is a ThreadPool?

A

A group of pre-initialized threads that can be reused for executing tasks.

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

True or false: Java supports multiple inheritance through classes.

A

FALSE

Java does not support multiple inheritance to avoid ambiguity.

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

What is Serialization in Java?

A

The process of converting an object into a byte stream for storage or transmission.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Fill in the blank: **Java's** default access modifier is _______.
package-private
26
Define **Java's final keyword**.
A modifier that prevents classes from being subclassed, methods from being overridden, or variables from being reassigned.
27
What is **Java's try-with-resources** statement?
A statement that automatically closes resources when done, preventing resource leaks.
28
True or false: **Java** supports primitive types as generic types.
FALSE ## Footnote Generics in Java only work with reference types.
29
What is a **Runnable** in Java?
An interface designed for classes whose instances are intended to be executed by a thread.
30
Fill in the blank: **Java's** method overriding requires the same _______ and _______.
name, parameters
31
Define **Java's volatile keyword**.
A modifier that indicates a variable's value may be changed by different threads.
32
What is a **BlockingQueue**?
A thread-safe queue that supports operations that wait for the queue to become non-empty when retrieving elements.
33
True or false: **Java** has a built-in support for functional programming.
TRUE ## Footnote Java 8 introduced lambda expressions and the Stream API.
34
What is **Java's assert statement**?
A debugging aid that tests a boolean expression and throws an AssertionError if false.
35
Fill in the blank: **Java's** main method can throw _______.
Exception
36
Define **Java's transient keyword**.
A modifier that prevents serialization of certain class attributes.
37
What is a **CompletableFuture**?
A class that represents a future result of an asynchronous computation.
38
What is **Java's main thread**?
The thread that executes the main method of a Java application.
39
Fill in the blank: **Java's** interface can extend _______.
other interfaces
40
Define **Java's static keyword**.
A modifier that indicates a member belongs to the class, rather than instances.
41
What is a **Future** in Java?
A placeholder for a result that may not yet be available.
42
True or false: **Java** has built-in support for multiple inheritance.
FALSE ## Footnote Java avoids multiple inheritance to prevent ambiguity.
43
What is **Java's default constructor**?
A constructor that does not take any parameters and is provided by the compiler.
44
Fill in the blank: **Java's** synchronized methods are used for _______.
thread safety
45
Define **Java's inner class**.
A class defined within another class, with access to its enclosing class's members.
46
What is a **StackOverflowError**?
An error thrown when a stack overflow occurs, typically due to deep recursion.
47
True or false: **Java** can use pointers.
FALSE ## Footnote Java does not support pointers for safety and simplicity.
48
What is **Java's main method** return type?
void
49
Fill in the blank: **Java's** String is _______ and immutable.
final
50
Define **Java's method overloading**.
Defining multiple methods with the same name but different parameters.
51
What is a **Semaphore** in Java?
A synchronization aid that controls access to a shared resource by multiple threads.
52
True or false: **Java** supports multiple inheritance through interfaces.
TRUE ## Footnote Java allows multiple inheritance via interfaces.
53
Fill in the blank: **Java's** List interface is part of the _______ package.
java.util
54
Define **Java's HashSet**.
A collection that contains no duplicate elements and has no defined ordering.
55
What is a **CountDownLatch**?
A synchronization aid that allows one or more threads to wait until a set of operations completes.
56
True or false: **Java** has a built-in garbage collector.
TRUE ## Footnote Java's garbage collector automatically manages memory.
57
What is **Java's ArrayList**?
A resizable array implementation of the List interface.
58
Define **Java's synchronized block**.
A block of code that can only be executed by one thread at a time.
59
What is a **ThreadLocal**?
A class that provides thread-local variables, each thread has its own value.
60
What is **Java's StringBuilder**?
A mutable sequence of characters, used for creating and modifying strings.
61
Define **Java's final class**.
A class that cannot be subclassed.
62
What is a **ForkJoinPool**?
A specialized implementation of ExecutorService for parallelism.
63
True or false: **Java** supports method references.
TRUE ## Footnote Method references are a feature introduced in Java 8.
64
What is **Java's ExecutorService**?
An interface that provides a higher-level replacement for managing threads.
65
Fill in the blank: **Java's** main method must be declared as _______.
public static void
66
Define **Java's volatile variable**.
A variable that is visible to all threads and prevents caching.
67
What is a **ThreadPoolExecutor**?
A flexible thread pool that can be configured for various execution policies.
68
True or false: **Java** has a built-in logging framework.
TRUE ## Footnote Java provides java.util.logging for logging purposes.
69
What is **Java's Map interface**?
An object that maps keys to values, with no duplicate keys allowed.
70
Define **Java's try-catch-finally** structure.
A mechanism for handling exceptions, with a block that executes regardless of exceptions.
71
What is a **CyclicBarrier**?
A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
72
True or false: **Java** supports default methods in interfaces.
TRUE ## Footnote Default methods were introduced in Java 8.
73
What is **Java's CompletableFuture**?
A class that represents a future result of an asynchronous computation.
74
Define **Java's static import**.
A feature that allows members (fields and methods) to be accessed without class qualification.
75
What is a **Phaser**?
A synchronization barrier that allows a set of threads to wait until a phase is completed.
76
True or false: **Java** has a built-in security manager.
TRUE ## Footnote The security manager enforces access controls at runtime.
77
What is **Java's Optional class**?
A container object which may or may not contain a non-null value.
78
Fill in the blank: **Java's** method overloading allows methods to have the same name with different _______.
parameter types
79
Define **Java's functional interfaces**.
Interfaces with a single abstract method, used primarily for lambda expressions.
80
What is a **ThreadFactory**?
An interface for creating new threads on demand.
81
What is **Java's Stream API**?
A feature for processing sequences of elements using functional-style operations.
82
Fill in the blank: **Java's** synchronized block is used to ensure _______.
thread safety
83
Define **Java's default methods**.
Methods in interfaces that have a body, allowing backward compatibility.