WorksheetsWorksheet Questions Extraction
Total questions: 86
Worksheet time: 43mins
Finalize method is associated with?
Construction
Serialization
Cloning
Garbage Collection (Pre-destruction)
G1 GC stands for?
Global 1
Generation 1
Garbage First
General One
Heap memory is used for?
Dynamic Object Allocation
Primitives
Code
Threads
If you pass an Object reference to a method, what is actually passed?
The memory address directly
A deep copy
A copy of the reference bits (Value of the reference)
The object itself
Immutability implies that an object's state…
Cannot be modified after creation
Is synchronized
Is transient
Can change anytime
Java Records introduced to reduce?
Boilerplate code for data carriers
Security
Compilation time
Performance
Recursive method calls without a base case lead to?
OutOfMemoryError
Heap Space Error
StackOverflowError
CPU Overheat
Static context cannot access?
Constants
this or super (Instance context)
Global vars
Static vars
Static methods and class definitions are stored in?
Stack
Young Generation
Old Generation
Metaspace (formerly PermGen)
Thread safety is inherent in?
Builders
Prototypes
To prevent inheritance, a class must be marked as?
Final
Sealed
Private
Static
Uninitialized boolean defaults to?
Null
False
True
1
Universal superclass in Java?
Root
Object
Entity
Main
Variable scope on the stack ends when?
Method returns
App stops
GC runs
Class unloads
Which memory segment holds method-local primitive types?
Native Stack
Heap
Metaspace
Stack
Wrapper classes allow primitives to be used in?
Collections (Generics)
Switch statements
Math operations
Loops
new String("xyz") creates objects in…
None
Pool only
Stack only
Both Heap and potentially String Pool
ConcurrentModificationException occurs when?
List is full
Modifying collection while iterating (without iterator's remove)
Map is empty
Thread sleep
Contract for equals() and hashCode()?
If equals is false, hashCode must be same
No relation
If hashCode is same, equals must be true
If equals is true, hashCode must be same
CopyOnWriteArrayList is best for?
Sorting
Large lists
Write-heavy
Read-heavy concurrent scenarios
Fast reading by index is a feature of?
HashSet
ArrayList
LinkedList
TreeSet
HashMap buckets typically contain?
Only values
Linked Lists (or Trees) of Entry nodes
Only keys
Arrays
HashSet lookup time?
O(n*n)
O(1) amortized
O(n)
O(log n)
Key collision in HashMap results in?
Overwriting the existing entry
Multiple entries chained in the same bucket (linked list or tree)
Throwing a runtime exception
Automatic key renaming
LinkedList get(i) complexity?
Logarithmic
Exponential
Linear O(n)
Constant
Map keys must implement correctly?
compareTo
run
hashCode and equals
serialize
Map interface extends Collection?
Indirectly
No
Yes
In Java 21
Natural ordering is defined by?
Comparable interface
Comparator
Equals
Hash
Sorted unique elements are found in?
HashMap
Vector
TreeSet
ArrayList
Stack implementation typically uses?
Sorted
FIFO
LIFO (Last In First Out)
Random Access
Treeify threshold for HashMap?
4
8
16
2
@Override usage is?
To indicate a method overrides a superclass or interface method
To declare a new class-level constant
To enable runtime reflection on private fields
To mark a constructor as default
Abstract class forces subclasses to?
Use super
Be final
Be static
Implement abstract methods (unless abstract themselves)
Composition suggests?
Copying code
Building classes from other classes (Has-A)
Splitting classes
Inheriting code
Conflicting default methods key solution?
Runtime error
First one wins
Class must override and explicitly choose (Class.super.method)
Compiler chooses
Constructors are not?
Public
Overloaded
Called
Inherited
Default methods in interfaces allow?
Constructors
Backward compatibility (adding method bodies)
Destructors
State
Diamond Problem relates to?
Multiple Implementation Inheritance ambiguity
Memory
Interfaces
Graphics
Final method prevents?
Access
Overriding
Execution
Overloading
Has-A relationship is?
Composition / Aggregation
Interface
Polymorphism
Inheritance
Interface instantiation?
Impossible ever
Only via reflection
Possible directly
Possible via Anonymous Inner Class
Liskov Substitution Principle implies?
Subtype must be substitutable for Base type
No inheritance
Interfaces only
Parent replaces Child
Multiple Inheritance of State is?
Mandatory
Forbidden in Java
Possible via Abstract classes
Allowed
Overriding depends on?
Static type
Runtime object type (Dynamic Binding)
Compiler
File name
Package-private access is default when?
Private is used
No modifier is specified
Public is used
Protected is used
SAM type stands for?
Synchronized Async Method
Static Access Mode
Single Abstract Method
Simple Abstract Model
Serializable is an example of?
Functional Interface
Marker Interface
Class
Annotation
White-box reuse refers to?
Copy-Paste
Composition
Libraries
Inheritance (Subclass knows internals)
Accumulate elements into a summary result?
Filter
Split
Reduce
Generate
Can you reuse a closed stream?
Sometimes
No, IllegalStateException
After reset
Yes
Declarative programming focuses on?
Steps
Result desired
Memory management
Control flow
Double colon operator (::) signifies?
Cast
Method Reference
Scope
Constructor
Finding one element and stopping?
findAny
forEach
sorted
peek
ForkJoinPool is used by? (MEDIUM)
JDBC
Serial Stream
IO Stream
Parallel Stream
Function that accepts value and returns void? (MEDIUM)
Predicate
Supplier
Operator
Consumer
Function that returns boolean? (MEDIUM)
Predicate
Supplier
Function
Consumer
Function
T get()
R apply(T t)
void apply()
boolean test(T t)
Merging multiple streams into one? (MEDIUM)
group
sort
flatMap
map
Operation for observing without changing? (MEDIUM)
Peek
Switch
Change
Map
Optional is essentially? (MEDIUM)
A primitive
A container object which may or may not contain a non-null value
A collection
A pointer
Parallel streams overhead logic? (MEDIUM)
Splitting and merging costs may outweigh benefits for small tasks
None
Linear
Always huge
Processing moves data? (MEDIUM)
To the code
Through the pipeline (Pull based)
To disk
To network
Transforming elements one-to-one? (MEDIUM)
reduce
filter
peek
map
forEach() is? (MEDIUM)
Optional
Helper
Intermediate
Terminal
Argument to avoid running tests? (HARD)
--no-tests
-DskipTests
-T 0
-Fast
Command to run unit tests?
mvn run
mvn test
mvn debug
mvn check
Descriptor for Maven?
package.json
build.xml
makefile
pom.xml
Gradle build script file?
pom.gradle
build.gradle
config.gradle
make.gradle
Indirect dependency is called?
Sub
Hidden
Implicit
Transitive
Inheritance in Maven?
Via Plugins
Via Parent POM
Via Copying
Not supported
Installing artifact to local repo?
mvn put
mvn copy
mvn save
mvn install
Local repo location usually?
/usr/local
~/.m2/repository
/bin
/lib
Maven uses XML, Gradle uses?
JSON
YAML
C++
Groovy / Kotlin DSL
Phase producing the artifact?
Test
Validate
Clean
Package
Removing build directory?
Wipe
Remove
Reset
Clean
Scope causing JAR to NOT be included in distribution?
Import
All
Provided
Compile
Scope for dependencies needed only for compiling tests?
Compile
Test
Runtime
System
Shaded Jar contains?
Code only
Encryption
Shadows
Dependencies unpacked and merged
Suffix '-SNAPSHOT' implies?
Photo
Work in progress / volatile
Backup
Read-only
Unique ID for a library in Maven?
ISBN
URL
GroupId + ArtifactId + Version
DOI
pom.xml tracks?
User data
Performance
Project configuration and dependencies
Bugs
A Bean in Spring is logically a...?
Managed object instantiated by the Container
Database row
Primitive
Coffee object
Annotation to resolve ambiguity?
@Qualifier
@One
@Select
@Pick
Are Singletons thread-safe by default?
No, developer must ensure statelessness
Yes
Yes, Spring locks them
Always
Bean A requires Bean B, Bean B requires Bean A error?
StackOverflow
Circular Dependency
Loop Error
Memory Leak
Context for web-aware request scope?
Servlet
ApplicationContext
BeanFactory
WebApplicationContext
