Java Java Core Interview Questions
288 questions with answers · Java Interview Guide
Exceptions, data types, generics, access modifiers, String handling, and the Object class. The foundation of every Java interview.
What is the difference between Checked and UNCHECked exceptions
Checked exceptions must be caught or declared (IOException), while unchecked exceptions extend RuntimeException and represent programming errors that don't require declaration.
try {
int x = Integer.parseInt("abc");
}
catch (NumberFormatException e) {
}
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}What methods in the Object class do you know
Key Object methods: equals(), hashCode(), toString(), clone(), wait(), notify(), notifyAll(), getClass(), finalize().
Object obj = new Object();
obj.hashCode();
obj.equals(new Object());
obj.getClass();
obj.toString();
obj.clone();Tell me about the hierarchy of exceptions
Throwable → Exception/Error; Exception → CheckedException/RuntimeException; RuntimeException → NullPointerException, IllegalArgumentException, etc.
try {
throw new RuntimeException("unchecked");
}
catch (Exception e) {
}
try {
throw new IOException("checked");
}
catch (IOException e) {
}What is the difference between the interface and the abstract class
Interfaces define contracts with abstract methods, supporting multiple inheritance; abstract classes provide partial implementation and state with single inheritance.
interface Drawable {
void draw();
}
abstract class Shape {
abstract void draw();
}
class Circle extends Shape implements Drawable {
@Override public void draw() {
}
}Tell me about Hashcode and Equals Contract
hashCode() and equals() must be consistent: equal objects have same hashCode; used together in hashing structures like HashMap to determine bucket placement and collision resolution.
class Person {
@Override public int hashCode() {
return id;
}
@Override public boolean equals(Object o) {
return this.id == ((Person)o).id;
}
int id;
}What is the difference between a primitive and a reference type of data
Primitives (int, boolean) store values directly on stack; reference types (objects) store memory address on stack, actual data on heap.
int primitive = 5;
Integer reference = new Integer(5);
int[] arr = {
1, 2, 3
}
;
String str = "hello";
primitive = 10;
reference = null;What do you know about Object class
Object is superclass of all Java classes; provides equals(), hashCode(), toString(), clone(), wait(), notify() methods; all classes inherit from Object.
class Demo extends Object {
public String toString() {
return "Demo";
}
public boolean equals(Object o) {
return super.equals(o);
}
public int hashCode() {
return super.hashCode();
}
}What are Hashcode and Equals overwritten rules
hashCode() and equals() must maintain: if two objects are equal (equals() returns true), they must have the same hashCode(); equals() must be reflexive, symmetric, transitive, and consistent; if you override equals(), always override hashCode().
class User {
int id;
String name;
public int hashCode() {
return id;
}
public boolean equals(Object o) {
return o instanceof User && this.id == ((User)o).id;
}
}What is the difference between final vs Finally vs Finalize
final makes variables immutable, finally is a block that always executes regardless of exceptions, finalize() is a deprecated Object method called before garbage collection.
final int x = 5;
try {
}
finally {
System.out.println("always runs");
}
protected void finalize() {
System.out.println("gc cleanup");
}What primitive data types are in Java
Java primitives are: byte, short, int, long, float, double, boolean, and char,stored on the stack with fixed memory sizes.
byte b = 1;
short s = 2;
int i = 3;
long l = 4L;
float f = 5.0f;
double d = 6.0;
boolean bool = true;
char c = 'a';What areas of memory in JVM do you know
JVM memory areas: Stack (local variables, method calls), Heap (objects, garbage collected), Method Area (class structures, constants), Program Counter, and Native Method Stack.
Object obj = new Object();
Thread t = new Thread(() -> {
}
);
int[] arr = new int[10];
String s = new String();Why do you need a class Object
Object class is the root of Java's class hierarchy, providing essential methods like equals(), hashCode(), toString(), clone(), and wait()/notify() for all objects.
class Parent {
}
class Child extends Parent {
}
Parent p = new Child();
Object o = new String();
((Object) p).equals(o);What is the difference between JDK and Jre
JDK (Java Development Kit) includes compiler, libraries, and tools for development; JRE (Java Runtime Environment) contains only the JVM and libraries needed to run Java applications. JDK is a superset of JRE.
class JDKvsJRE {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
System.out.println(System.getProperty("java.home"));
}
}What is Hashcode
Hashcode is an integer value generated by the hashCode() method representing an object's memory address or custom logic. It's used for hash-based collections to determine bucket placement; objects considered equal must return the same hashcode.
class HashCodeEx {
public static void main(String[] args) {
String s = "hello";
System.out.println(s.hashCode());
System.out.println("hello".hashCode());
}
}What is a string pool
String pool is a memory region storing unique string literals in Java heap. When a string literal is created, JVM checks the pool first; if it exists, the reference is returned instead of creating a new object, saving memory.
class StringPoolEx {
String s1 = "hello";
String s2 = "hello";
String s3 = new String("hello");
System.out.println(s1 == s2);
System.out.println(s1 == s3);
}What is an iterator and why it is needed
Iterator is an interface for traversing collections sequentially using hasNext() and next(). It's needed to provide a uniform way to access elements regardless of underlying collection type and enables safe removal during iteration.
class IteratorEx {
List<String> list = Arrays.asList("a", "b");
Iterator<String> it = list.iterator();
while(it.hasNext()) System.out.println(it.next());
}What is the difference between the MAP operation and Flatmap
map() transforms each element to one output element maintaining 1:1 mapping; flatMap() transforms each element to a stream and flattens all streams into a single stream. Use flatMap when transformation produces multiple elements per input.
List<List<Integer>> nested = Arrays.asList(Arrays.asList(1,2), Arrays.asList(3,4));
List<Integer> mapped = nested.stream().map(List::size).collect(Collectors.toList());
List<Integer> flatMapped = nested.stream().flatMap(List::stream).collect(Collectors.toList());What types of data are in Java
Java has 8 primitive types: byte, short, int, long, float, double, boolean, char. All others are reference types (objects) stored on heap, while primitives are stored on stack.
byte b = 10;
short s = 20;
int i = 30;
long l = 40L;
float f = 5.5f;
double d = 6.6;
boolean bool = true;
char c = 'A';What is encapsulation
Encapsulation bundles data (state) and methods (behavior) together while hiding internal details behind access modifiers. It provides data protection, maintainability, and allows controlled access through getters/setters.
class BankAccount {
private double balance;
public void deposit(double amount) {
balance += amount;
}
public double getBalance() {
return balance;
}
}What is the main idea of Equals and Hashcode
equals() method checks logical equality of object content; hashCode() returns integer representation. Contract: equal objects must have same hashcode, but not vice versa. Both override defaults for proper behavior in hash-based collections and comparisons.
class Person {
private String name;
public boolean equals(Object o) {
return this.name.equals(((Person)o).name);
}
public int hashCode() {
return name.hashCode();
}
}What are access modifiers and what are they
Access modifiers control visibility: public (everywhere), protected (same package + subclasses), package-private/default (same package only), private (same class only). They enforce encapsulation and API boundaries.
class AccessModifiers {
public int pub = 1;
private int priv = 2;
protected int prot = 3;
int packagePrivate = 4;
}What do you know about String
String is an immutable, final class representing sequences of characters stored in the string pool. Immutability ensures thread-safety and allows reuse; String concatenation creates new objects; use StringBuilder for mutable operations.
String s = "hello";
String s2 = new String("hello");
System.out.println(s == s2);
System.out.println(s.equals(s2));
s = s + " world";What is an exception
Exception is a checked or unchecked event that disrupts normal program flow. Checked exceptions (IOException, SQLException) must be caught/declared; unchecked exceptions (RuntimeException, NullPointerException) are not mandatory to handle.
try {
int x = 10 / 0;
}
catch (ArithmeticException e) {
System.out.println("Error: " + e.getMessage());
}
finally {
System.out.println("Cleanup");
}What is a keyword Final
Final on classes prevents inheritance, on methods prevents overriding, on variables makes them immutable after initialization.
final String constant = "immutable";
final class FinalClass {
}
final void finalMethod() {
}
int[] arr = {
1, 2, 3
}
;
final int[] finalArr = arr;
finalArr[0] = 99;What is Finalize
Finalize is a deprecated method called by garbage collector before object destruction; it's unreliable and should be replaced with try-with-resources or AutoCloseable.
class Parent {
protected void finalize() throws Throwable {
System.out.println("Cleanup");
super.finalize();
}
}
Parent p = new Parent();
p = null;
System.gc();Is it possible to override static methods
No, static methods cannot be overridden; they can be redefined in subclasses (method hiding) but not truly overridden due to compile-time binding.
class Parent {
static void display() {
System.out.println("Parent");
}
}
class Child extends Parent {
static void display() {
System.out.println("Child");
}
}
Parent.display();
Child.display();What makes the key word transient
Transient marks fields to be excluded from serialization; when an object is deserialized, transient fields receive default values.
class User implements Serializable {
transient String password;
public static void main(String[] args) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("user.bin"));
oos.writeObject(new User());
}
}What is the difference between Supplier and Consumer
Consumer accepts a value and returns void (side effects); Supplier takes no arguments and returns a value; opposite functional interfaces for data flow.
Supplier<String> supplier = () -> "Hello";
Consumer<String> consumer = s -> System.out.println(s);
consumer.accept(supplier.get());What is the idea of polymorphism
Polymorphism allows objects of different types to be treated through a common interface; enables runtime method resolution and flexible, extensible code design.
class Animal {
void sound() {
}
}
class Dog extends Animal {
@Override void sound() {
System.out.println("Woof");
}
}
Animal a = new Dog();
a.sound();What do you know about the Clone method
Clone() creates a shallow copy of an object; requires implementing Cloneable and overriding the method; deep copy requires manual field cloning.
class Person implements Cloneable {
String name;
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
Person p = (Person) new Person().clone();
}What is the idea of Stream API
Stream API provides functional-style operations (map, filter, reduce) on collections with lazy evaluation, enabling concise, composable data transformations.
List<Integer> list = Arrays.asList(1,2,3,4,5);
list.stream().filter(n -> n > 2).map(n -> n * 2).forEach(System.out::println);How can I implement multiple inheritance in Java
Use multiple interface implementation (classes can implement multiple interfaces) or composition; Java doesn't support true multiple inheritance to avoid the diamond problem.
interface A {
void methodA();
}
interface B {
void methodB();
}
class C implements A, B {
public void methodA() {
}
public void methodB() {
}
}What does Garbage Collector work with
Garbage Collector manages heap memory by identifying and removing unreferenced objects, using algorithms like mark-sweep or generational collection to free unused memory automatically.
Object obj = new String("test");
obj = null;
System.gc();
obj = new Integer(42);What is a line in Java
A line in Java refers to a single statement or instruction terminated by a semicolon; it's the basic executable unit of code.
String line = new BufferedReader(new InputStreamReader(System.in)).readLine();How the Try With Resources operator works
Try-with-resources automatically closes resources implementing AutoCloseable in the try declaration, eliminating manual finally blocks and preventing resource leaks.
try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
String line = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}Can a primitive data type to get into HIP
No, primitive data types are stored on the stack, not the heap (HIP); only objects are allocated on the heap.
Integer num = 128;
Integer num2 = 128;
System.out.println(num == num2);What methods are located in the interface
Interfaces contain abstract methods, default methods (Java 8+), static methods, and constants; all methods define contracts for implementing classes.
What is the relationship of the Equals and Hashcode contract
Equals and hashCode must be consistent: if two objects are equal via equals(), they must return the same hashCode to function correctly in hash-based collections.
Stringbuilder and Stringbuffer, what are the differences
StringBuilder is unsynchronized and faster for single-threaded use; StringBuffer is synchronized and thread-safe but slower, suited for concurrent environments.
What do you know about the Java 8+ functional interface
A functional interface has exactly one abstract method and enables lambda expressions and method references; marked with @FunctionalInterface annotation since Java 8.
Why is it impossible to compare objects through "=="
The '==' operator compares references (memory addresses), not object content; use equals() to compare actual object values.
What types of data exist in Java
Java has 8 primitive types (byte, short, int, long, float, double, boolean, char) and reference types (classes, interfaces, arrays).
The main idea of encapsulation
Encapsulation bundles data and methods together while hiding internal details through access modifiers, protecting state and enforcing controlled access.
What is the meaning of incapsulation
Encapsulation (same as incapsulation) restricts direct access to object internals via private fields with public getter/setter methods, maintaining data integrity.
Why do you need String Pool
String Pool is a memory optimization that stores unique String literals in a dedicated pool, avoiding duplicate objects and reducing heap consumption.
What is Parallel Stream
Parallel Stream processes elements concurrently across multiple threads using fork-join framework, improving performance for large datasets on multi-core systems.
What is String Pool
String Pool is a special memory region in the heap that caches immutable String objects, reusing references when identical strings are created.
What is JVM, JDK, Jre
JVM is the runtime engine executing bytecode, JDK includes compiler and development tools, JRE contains only the runtime to execute compiled code.
What is a line in Java
A thread in Java is the smallest unit of execution within a process; it's created from Thread class or Runnable interface and executes code concurrently.
What is the idea of polymorphism
Polymorphism allows objects of different types to be treated uniformly through a common interface, enabling method overriding and overloading for flexible code design.
Is it possible to override static methods
No, static methods cannot be overridden; they are resolved at compile-time based on reference type, not runtime type like instance methods.
How can I implement multiple inheritance in Java
Java doesn't support multiple inheritance directly, but you can achieve it using interfaces where a class implements multiple interfaces.
What methods are located in the interface
Interfaces contain abstract methods (pre-Java 8), default methods, static methods, and constants; Java 8+ allows default and static method implementations.
What is the idea of Stream API
Stream API provides a functional approach to process collections using lazy evaluation and method chaining (map, filter, reduce) for concise, readable code.
What is Finalize
Finalize is a deprecated method called by garbage collector before object deletion; it's unreliable and should be avoided,use try-with-resources instead.
What is the relationship of the Equals and Hashcode contract
Equals and hashCode contract states: if equals() returns true, hashCode() must return same value; violation breaks HashMap/HashSet functionality.
The main idea of encapsulation
Encapsulation hides internal implementation details behind public methods, controlling access through access modifiers (private, public, protected) for security and maintainability.
Stringbuilder and Stringbuffer, what are the differences
StringBuilder is non-synchronized and faster for single-threaded use; StringBuffer is synchronized (thread-safe) but slower, appropriate for multi-threaded environments.
What is JVM, JDK, Jre
JVM (Java Virtual Machine) executes bytecode platform-independently; JDK (Java Development Kit) includes compiler, JVM, and tools for development; JRE (Java Runtime Environment) contains JVM and libraries for running applications.
What types of data exist in Java
Java has primitive types (byte, short, int, long, float, double, boolean, char) and reference types (objects, arrays, strings).
Can a primitive data type to get into HIP
Yes, primitive types can be stored in the heap when boxed as wrapper objects (Integer, Double, etc.) or used within objects, though they're naturally stack-allocated.
What is the keyword transient
Transient is a modifier that excludes fields from serialization; marked fields are not included in the serialized object stream.
What is String Pool
String Pool is a memory region that stores unique string literals; when a string is created, it's checked against the pool to reuse existing instances and save memory.
What is the meaning of incapsulation
Encapsulation bundles data and methods together while hiding internal details through access modifiers, controlling how data is accessed and modified.
Why is it impossible to compare objects through "=="
"==" compares object references (memory addresses), not content; use .equals() for content comparison or implement it to define equality logic.
Why do you need String Pool
String Pool saves memory by avoiding duplicate string instances; identical literals reference the same object, reducing heap consumption in memory-constrained environments.
How the Try With Resources operator works
Try-with-resources automatically closes resources implementing AutoCloseable; the resource is declared in parentheses after 'try' and closed in reverse order of creation.
What do you know about the Java 8+ functional interface
Functional interfaces have single abstract method, enabling lambda expressions and method references; common examples are Runnable, Callable, Comparator, and Function.
What is Parallel Stream
Parallel Stream processes data in parallel using multiple threads; it divides the stream into chunks, processes them concurrently via ForkJoinPool, then combines results.
What does Garbage Collector work with
Garbage Collector works with heap memory, tracking objects and reclaiming unreachable instances; it uses algorithms like mark-sweep, generational collection, and G1GC.
What happens in JVM when starting a program written on Java
JVM loads the class file, performs bytecode verification, initializes static variables and blocks, executes main() method, and manages memory via garbage collection during execution.
What can tell about the jar file manifesto
JAR manifest (META-INF/MANIFEST.MF) contains metadata like Main-Class entry point, Class-Path dependencies, version info, and custom attributes for the application.
Tell me about the memory areas and Garbage Collector
JVM memory includes heap (shared, GC-managed objects), stack (thread-local, method frames), metaspace (class metadata), and code cache (compiled JIT code); GC removes unreachable objects via mark-and-sweep or generational strategies.
How can you understand that an object is used in memory or not, provided that objects have a cyclic link to each other
JVM determines reachability via GC root references; cyclic references are collected if not reachable from root objects, as GC uses reachability analysis, not reference counting.
What areas of memory can you remember except stack and heaps
Besides stack and heap: metaspace (class metadata), code cache (JIT compiled code), and off-heap memory (direct buffers).
What are the disadvantages of a pool of lines in terms of security
String pool security risks include denial-of-service via hash collisions and accidental string sharing between untrusted domains; mitigate with -XX:StringTableSize tuning and input validation.
Is the Poole of the Lines empty at the start of the JAR file or there are some values there
String pool is not empty at JVM start; JVM initializes it with commonly used strings and bootstrap class strings for optimization.
Due to what LambDA explorations work, which occurs "under the hood"
Lambda expressions compile to synthetic methods using invokedynamic bytecode instruction; javac generates a private static method and bootstrap method handles runtime method handle linkage.
You use in the work of lambda expression
Lambda expressions are used for functional interfaces, stream operations (map, filter), event handling, and callbacks to reduce boilerplate compared to anonymous classes.
How many functionality can be placed in one lambda expression
One lambda expression body can contain multiple statements if wrapped in braces {}, but single expressions are preferred; use semicolons to separate statements and return keyword if needed.
Where do Equals and Hashcode methods come from
Equals and Hashcode come from the Object class, which is the root of Java's class hierarchy; all objects inherit these methods.
Why Hashcode can be equal
Multiple objects can have the same hashCode because hashCode only provides a bucket location; equals() determines actual equality.
What do you know about the memory models in Java
Java Memory Model ensures visibility and ordering of shared variable access across threads through happens-before relationships and synchronization guarantees.
When Stream begins its execution
Streams execute lazily; execution begins when a terminal operation (like collect(), forEach(), or reduce()) is invoked on the stream.
What is Default Equals and Hashcode modifier
Default equals() and hashCode() are public methods inherited from Object class; equals uses reference comparison, hashCode uses object memory address.
What is Heap, Stack
Stack stores primitive values and references (LIFO, thread-local, automatically freed); Heap stores objects (shared, garbage-collected, slower access).
What are the problems during the implementation of hashcode
Main issues: collision handling, mutable objects causing hash changes, inconsistent implementation between equals() and hashCode(), and poor hash distribution.
What is the eraser of the types for
Type erasure removes generic type information at compile-time to maintain backward compatibility; generics exist only during compilation.
From how many classes the class can be inherited
A class can directly inherit from only one class; however, it can implement multiple interfaces to achieve multiple inheritance of type.
How to create your own annotation
Create custom annotations using @interface keyword, define optional methods with default values, and apply meta-annotations like @Retention and @Target.
Which two classes are not inherited from Object
No classes are excluded from inheriting Object; all classes (except Object itself) inherit from Object, including interfaces in object context.
What is the grinding of types
Type grinding (erasure) removes generic type parameters at runtime; List<String> becomes List, so generics are compile-time only.
How the parameters are transmitted
Parameters are transmitted by value in Java; for primitives, the value is copied; for objects, the reference (address) is copied, not the object itself.
Tell me the features of the Java language
Key features: object-oriented, platform-independent (bytecode), automatic garbage collection, strong type-checking, multi-threading support, and exception handling.
How Java helps to run the code on operating systems
Java achieves OS independence through the JVM (Java Virtual Machine), which interprets bytecode; the JVM is OS-specific, bytecode is not.
How data is stored in Java
Data is stored as objects on the heap with references on the stack; primitives are stored directly on the stack; memory is managed by the garbage collector.
How to determine which object is garbage
Objects become garbage when they're unreachable from any live reference; the GC periodically identifies and frees unreferenced objects.
Can developers manage the assembly of garbage and memory parameters
Developers can suggest garbage collection via System.gc() or Runtime.gc(), but cannot force it; memory parameters are controlled via JVM flags like -Xmx and -Xms.
What is a class in Java
A class is a blueprint for creating objects; it defines properties (fields), behaviors (methods), and can extend another class or implement interfaces.
What is the class consist of
A class consists of fields (state), methods (behavior), and constructors; it's the blueprint for creating objects.
How can you compare objects in Java in Java
Use equals() method for logical comparison of object content, or == operator to compare object references in memory.
What versions of Java worked with
Name the Java versions you have actually used in production and highlight what features you leveraged from each. For example: Java 8 (streams, lambdas, Optional), Java 11 (var, HttpClient), Java 17 (records, sealed classes), Java 21 (virtual threads). If you only know Java 8, that is fine, just be honest about it.
What is the noteworthy Java in the context of the platform
Java's platform independence (write once, run anywhere) through bytecode compilation and JVM is the most noteworthy aspect.
What is Garbage Collector
Garbage Collector automatically reclaims memory by removing unreachable objects, eliminating manual memory management and preventing memory leaks.
After what moment GC understands that you need to collect garbage
GC identifies garbage when objects become unreachable,no references point to them from the root set or live object graph.
What GC do you know
Common GCs include G1GC (default in Java 11+), CMS, Parallel GC, Serial GC, and newer ZGC and Shenandoah for low-latency applications.
How can we set the GC configuration parameters
Configure GC via JVM flags like -XX:+UseG1GC, -Xms, -Xmx for heap size, or -XX:MaxGCPauseMillis for pause time targets.
What plugins can be put when creating a virtual machine
Plugins/extensions for VM creation typically include profilers, debuggers, APM agents, and custom classloaders depending on the framework.
What is the difference between Equals and Hashcode
equals() compares object content semantically, while hashCode() returns an integer hash; they must be consistent,equal objects must have equal hash codes.
Why is it important to override Equals and Hashcode
Overriding both is critical for using objects in hash-based collections (HashMap, HashSet); without it, lookups fail despite logical equality.
In the context of the business, is it necessary to take into account in Equals all the fields of the essence
Depends on business requirements; include only fields relevant to business identity,not all fields necessarily belong in equality logic.
Tell me briefly about the idea of processing errors in Java.
Java uses checked exceptions (compile-time) and unchecked exceptions (runtime); handle with try-catch-finally or try-with-resources for resource management.
What designs in the processing of errors do you know
Try-catch for specific handling, try-with-resources for automatic resource closing, try-catch-finally for cleanup, and throws for delegation.
Когда может произойти ситуация, когда мы можем перезатереть исключение
Exception overwriting occurs when a new exception is thrown in finally block, masking the original exception from try block,use suppressed exceptions to preserve both.
Where in the processing of exceptions a design with Finally can be used
Finally block executes regardless of exception occurrence; use it for resource cleanup (closing streams, connections) or guaranteed cleanup logic.
What is the value of the byte
Byte is a signed 8-bit primitive integer type with range -128 to 127; useful for low-level I/O and memory-constrained scenarios.
What needs to be done in order to override hashcode
Override hashCode by implementing equals() first, then ensure equal objects return same hash code using prime multiplier (31) with object fields; violating this breaks HashMaps/HashSets.
How the line "under the hood" works
String concatenation using + operator is converted to StringBuilder by compiler; multiple concatenations in loops create new StringBuilder instances for each operation.
How to bring a line into arrays of characters
Use toCharArray() method on String to convert it to char array: String str = "hello"; char[] chars = str.toCharArray();
What is ensured by immutable
Immutability ensures thread-safety without synchronization, prevents accidental modification, enables safe caching, and allows use as HashMap keys.
What characteristics should the method have a functional ITERPHIS to function
A functional interface must have exactly one abstract method; it can have default/static methods; marked with @FunctionalInterface annotation for compile-time checking.
What needs to be done in order to accept and return values
Methods accept parameters in parentheses and return values using return keyword with specified return type; void methods don't return anything.
Can we without jdk lead java development
No, JDK is required for Java development as it includes compiler (javac), runtime (JRE), and tools; JRE alone only runs compiled code.
Explain what is due to the fact that int is limited in the amount
int is 32-bit signed primitive limited to -2^31 to 2^31-1; use long for larger values or BigInteger for arbitrary precision numbers.
Where reference data types are stored
Reference data types (objects, arrays, strings) are stored on heap memory; the reference variable itself is stored on stack.
Can I use Equals in the form in which it is
equals() should be overridden when comparing object content; default Object.equals() only compares references, not field values.
What is the difference between the abstract class and the abstract method, and the abstract method and interface
Abstract class can have constructors and both abstract/concrete methods; abstract method is unimplemented in abstract class; interface has no constructor and all methods were abstract (now can have default/static methods in Java 8+).
What is dynamic polymorphism
Dynamic polymorphism is runtime method resolution based on actual object type not reference type; achieved through method overriding and inheritance.
What is the idea of overloading constructors
Constructor overloading allows multiple constructors with different parameter lists to provide flexible object initialization options.
Why is immutable so important
Immutability provides thread-safety, enables safe caching, allows use as HashMap keys, and prevents unintended state changes in multi-threaded environments.
What is the difference between JVM from JDK
JVM is the virtual machine executing bytecode; JDK includes JVM, compiler (javac), and development tools; JRE includes JVM and libraries only.
Do we always need to override Equals
Override equals() only when you need custom comparison logic; default Object.equals() (reference equality) is sufficient for many classes.
Why Java platform is independent
Java bytecode runs on any JVM-installed platform without recompilation; 'Write Once Run Anywhere' principle achieved through JVM abstraction layer.
What is the reason for the incomplete Java object
Java objects are incomplete by design allowing subclasses to extend behavior; abstract classes force subclasses to implement specific contracts.
What is Wrapper class
Wrapper classes (Integer, Double, Boolean) wrap primitive types as objects enabling use in collections, null values, and method parameters requiring objects.
Have you heard something about Boxing/Unboxing
Boxing automatically wraps primitives in wrapper objects (Integer, Double, etc.), while unboxing extracts the primitive value; both happen implicitly in Java 5+ and can cause NullPointerException if unboxing null.
What is the difference between the method and the constructor
Methods perform actions and can be overridden; constructors initialize objects, cannot be overridden (only overloaded), and are called once at instantiation.
Is it possible to override the method? And the constructor
Methods can be overridden in subclasses to provide specific behavior; constructors cannot be overridden but can be overloaded with different parameters.
What are heterogeneous types
Heterogeneous types refer to collections storing different object types (e.g., List<Object>), relying on polymorphism and requiring explicit casting to access specific type methods.
How to store and process a password working with java
Store passwords as char[] instead of String to allow secure zeroing after use; always hash with bcrypt/PBKDF2/Argon2 before storage, never encrypt alone.
Where it would be worth applying enum transfers
Enums are ideal for fixed sets of constants like HTTP methods, status codes, or state machines where you need type-safety and prevent invalid values.
What are the most important methods and are used most often
Most commonly used: toString(), equals(), hashCode(), getClass(), clone(); understanding their contracts is essential for proper object behavior.
Whether it was necessary to overlook Equals on their own
Yes, always override equals() when implementing value-based equality; otherwise, default reference equality may not match your business logic requirements.
How lines are stored in memory
Strings are stored in the String pool (heap memory) for immutable, interned literals; duplicate strings reference the same object, saving memory.
What is the problem of concatenation
String concatenation with '+' creates new String objects for each operation, causing memory inefficiency in loops; use StringBuilder for multiple concatenations.
Someday I tried the Append method
Append method (StringBuilder/StringBuffer) efficiently adds to the string buffer without creating intermediate objects, solving concatenation performance issues.
What is the difference between Error and Exception
Exception is checked (compiler-enforced), recoverable, extends Throwable; Error is unchecked, unrecoverable, indicates JVM problems like OutOfMemoryError.
Give an example of error at JVM level
StackOverflowError occurs from infinite recursion, OutOfMemoryError from heap exhaustion, NoClassDefFoundError when JVM cannot load a required class at runtime.
What is the problem of verified exceptions
Checked exceptions force verbose try-catch blocks, reduce code readability, and mix error handling with business logic; many prefer unchecked exceptions for better design.
Would you delete exceptions from Java Checked
No, checked exceptions should remain; they enforce contract clarity and prevent silent failures, though they should be used judiciously for truly recoverable errors.
Give examples where CHECKED would use
Use checked exceptions for recoverable conditions: IOException for file operations, SQLException for database failures, InterruptedException for threading operations.
Can I make an improved For Each cycle for my object
Yes, implement Iterable interface and provide an Iterator implementation; enables enhanced for-loop: for(MyType item : myObject) by implementing iterator() method.
What is the most useful method in Object
clone() is most useful as it provides shallow copying; equals() and hashCode() are critical for collections; toString() aids debugging.
What is the advantage of Package Private
Package-private (default access) restricts visibility to the same package, preventing external dependencies and allowing safer internal API refactoring within the package.
How Package Private can be associated with encapsulation
Package-private enforces encapsulation by hiding implementation details from outside packages; it creates clear module boundaries and allows package-level access control without public/private extremes.
Which design template is used for Stringbuilder and Stringbuffer
Builder pattern. StringBuilder and StringBuffer use the Builder pattern to construct strings efficiently through method chaining.
Can an array be attached to stream
Yes, arrays can be attached to streams using Arrays.stream() which returns a Stream interface for array elements.
What is the coolest method in straps
The toString() method is commonly considered powerful as it provides string representation, but if referring to Streams, forEach() or collect() are essential.
What do you know about TargetMethod
TargetMethod appears to be a non-standard term; if referring to reflection, Method class allows invoking target methods dynamically via invoke().
What I heard about Optional class
Optional is a container for null-safe value handling; it wraps potentially null values and provides functional methods like map(), filter(), orElse() to avoid NullPointerException.
Is it necessary to create a class in Java
No, not always. You can write executable code in interfaces (with static/default methods) or enums, but classes are the primary construct for most OOP code.
What 3 principles are basic in the OOP
OOP's three core principles: encapsulation (data hiding), inheritance (code reuse), polymorphism (method overriding/interface implementation).
Where you can apply the polyformity of polymorphism
Polymorphism applies in method overriding (runtime), method overloading (compile-time), and through interfaces/abstract classes where different implementations handle the same contract differently.
Where you can see comprehensive data on primitive types of data in Java
Primitive types documentation is found in the Java Language Specification and Java.lang.reflect; includes byte, short, int, long, float, double, boolean, char with their size and range specs.
What are reference data types
Reference types are objects pointing to memory addresses: classes, interfaces, arrays, and enums,passed by reference, not by value like primitives.
That in Java is the most important object for all
The Object class is the root superclass of all Java classes; every class implicitly extends it.
Object classes are inherited clearly or implicitly
Object classes are inherited implicitly; all classes automatically extend Object even without explicit declaration.
What determines the equivalence of one object to another
Equivalence is determined by the equals() method, which by default uses reference equality (==) but can be overridden to compare object state.
You can characterize what such a state
State refers to the current values of an object's fields/properties at any given point in time.
Do you know the difference between Stringbuilder and concatenation
StringBuilder is mutable and faster for multiple concatenations; string concatenation with + creates new String objects each time, causing memory overhead and poor performance.
Than open fields fraught
Public fields expose implementation details, violate encapsulation, prevent validation control, and make refactoring dangerous if accessed externally.
What I heard about the static of typification in Java
Static typing in Java means variable types are checked at compile-time; type must be declared and respected, preventing type-related runtime errors.
What is the string and features in Java
String is immutable, stored in String Pool for memory efficiency, implements Comparable, and thread-safe; created via literals or new String().
What is the Equals method
equals() compares object content/state; default implementation checks reference equality (==), but overriding allows semantic equality comparison.
What implies immutable
Immutable means an object's state cannot be changed after creation; examples include String, Integer, LocalDate,ensures thread-safety and can be safely shared.
What is the strict typification in Java expresses itself
Strict typing expresses itself through compile-time type checking, no implicit type conversions between incompatible types, and generic type safety preventing ClassCastException at runtime.
What two main sections of memory for storing data are there
Heap stores objects and arrays (dynamically allocated, garbage collected); Stack stores primitives and method references (LIFO, automatically freed).
Have you heard about Stackoverflow
StackOverflow is a Q&A platform; in Java context, it refers to a runtime error when the call stack exceeds its memory limit, typically from infinite recursion.
As it were substantiated that the interface exists
Interfaces are verified at compile-time through type checking; at runtime, instanceof checks and reflection can confirm if a class implements an interface.
Which underlies each exception
All exceptions inherit from Throwable; checked exceptions extend Exception (must be caught/declared), unchecked extend RuntimeException (optional handling).
How to process exceptions
Use try-catch blocks to catch exceptions, finally block for cleanup, or throws keyword to propagate; Java 7+ try-with-resources auto-closes resources.
As if threw up the exceptions
Throw exceptions using 'throw new ExceptionType(message)' for checked exceptions in method body; must declare in method signature or handle with try-catch.
How long lines are stored in String
Strings are stored as char arrays in the String object; internally uses a value field containing the character sequence.
Stringpool - part of Heap or something separate
String pool is part of the Heap memory (permgen in Java 8-, metaspace in Java 9+); it's not a separate memory region.
What is Autocloseable and the Try-With-Rosources design
AutoCloseable interface with close() method; try-with-resources automatically calls close() on resources, ensuring cleanup even on exceptions.
What is the idea in Geneeric generalizations
Generics provide compile-time type safety and eliminate casting; enable writing reusable code with type parameters (e.g., List<String>).
Have you heard about new chips of the latest versions of Java
Recent Java versions include records (Java 14+), sealed classes (Java 15+), pattern matching (Java 16+), and virtual threads (Java 21+).
How to override the Equals method
Override equals() by checking type, comparing field values using == or equals(); must maintain consistency with hashCode().
What is the difference between String and Stringbuilder
String is immutable, fixed-length, slower for concatenation; StringBuilder is mutable, faster for multiple concatenations, not thread-safe.
What are the terms of the Equals and Hashcode contract
equals() contract: reflexive (x.equals(x)=true), symmetric, transitive; hashCode() must return same value for equal objects (allows consistent HashSet/HashMap use).
Features of the String class
String is immutable, thread-safe, stored in string pool for optimization, and has built-in methods for manipulation like substring, concat, and equals.
Do you know what a static class is
A static class cannot be instantiated and all its members are static; in Java, only nested classes can be static, used for grouping related utility methods.
What is a deep copying
Deep copying creates a complete independent copy of an object including all nested objects, unlike shallow copy which only copies references to inner objects.
What is the main idea of reflection
Reflection allows runtime introspection and manipulation of classes, methods, fields, and constructors, enabling dynamic instantiation, method invocation, and annotation processing.
What is Jre
JRE is the Java Runtime Environment containing JVM, class libraries, and tools needed to execute Java applications without compilation.
What terminal operations do we have
Terminal operations in streams include collect(), forEach(), reduce(), count(), anyMatch(), allMatch(), and findFirst() which produce final results or side effects.
How are the problems of memory deficiency and exclusion of Out of Memory Exception are resolved
OutOfMemoryException is resolved through garbage collection tuning, heap size configuration (-Xmx), memory leak detection, and object pooling strategies.
What is Java constructor
A constructor is a special method with the same name as the class used for object initialization; it can be overloaded and doesn't have a return type.
Why is the Assert Operator used
Assert validates assumptions during development; throws AssertionError if condition fails; disabled by default in production (-ea flag enables).
How to get access to the field of the external class from the invested class
Access external class fields from inner classes through the outer class reference (OuterClass.this.field) or via public/protected accessors; private fields require getter methods.
What is the "local class", what are its features
Local classes are classes defined within method scope, non-instantiable outside that method, cannot be static, and can access final/effectively final local variables.
What will happen to the garbage collector if the execution of the finalize () method requires significantly a lot of time, or during the execution the exception will be released
If finalize() takes excessive time or throws exceptions, garbage collection blocks,the thread hangs and other finalizers queue up, potentially causing memory issues or application freeze.
What are "anonymous classes" where they are used
Anonymous classes are unnamed inner classes defined inline at instantiation; used for one-time implementations of interfaces/abstract classes in event handlers, callbacks, and functional programming.
What are the features of the use of nested classes: static and internal, which is the difference between them
Static nested classes don't hold outer instance reference, are true members accessible via OuterClass.InnerClass, and behave like regular classes; non-static inner classes hold implicit outer reference and access instance members.
Tell me about the invested classes in what cases they are applied
Nested classes encapsulate related functionality, improve code organization, and provide access control; used for factory patterns, utility classes, and event handlers within a logical scope.
What types of classes are in Java
Java has nested classes (static, non-static), inner classes, anonymous classes, and local classes; top-level classes can only be public, package-private, or implicitly package-private.
Where the initialization of static/non -tatual fields is allowed
Static fields initialize in static blocks or at class loading time; instance fields initialize in constructors, instance initializers, or at declaration; both executed in definition order.
What is the difference between a member of a class copy and a static class member
Instance members belong to each object and accessed via 'this'; static members belong to the class itself, shared across all instances, accessed via class name.
Is it possible to declare the method abstract and static at the same time
No, a method cannot be both abstract and static,abstract requires overriding in subclasses but static prevents overriding (bound at compile time), creating a logical contradiction.
How to access overstroting parental methods
Access overridden parent methods using super.methodName() to call the parent class implementation.
Is it possible to narrow the access level/type of the returned value when the method is redistributed
Yes, you can narrow the return type in an overridden method (covariant return types); for example, a subclass method can return a subtype of the parent's return type.
Can non -non -static methods can overload static
No, static methods cannot be overloaded by non-static methods; overloading requires same signature, and static/non-static differ in binding mechanism (not true overloading but shadowing).
What an exception is released when an error occurs in the class initialization unit
ExceptionInInitializerError is thrown when an error occurs in a static initializer block or field initialization; it wraps the underlying exception (e.g., NullPointerException).
What are "anonymous classes" where they are used
Inner classes without names, defined inline at point of use; used for event listeners, callbacks, simple strategy implementations.
What will happen to the garbage collector if the execution of the finalize () method requires significantly a lot of time, or during the execution the exception will be released
GC pauses while finalize() executes; long-running or exception-throwing finalize() delays garbage collection and degrades performance.
Why is the Assert Operator used
Assert validates assumptions during development and testing (assert condition : message); disabled in production with -ea flag.
How to get access to the field of the external class from the invested class
Use getter/setter methods, package-private access, or reflection; outer class members accessible directly from inner class.
What is the "local class", what are its features
Local class defined inside method/block, scoped to that block only, can access final/effectively final variables, cannot be static or public.
What are the features of the use of nested classes: static and internal, which is the difference between them
Static nested class: no implicit outer reference, can access outer static members only. Inner class: holds implicit reference, accesses all outer members; inner preferred for logical grouping.
Tell me about the invested classes in what cases they are applied
Inner classes used for logical grouping, event handlers, callbacks; anonymous classes for one-time implementations.
What types of classes are in Java
Concrete, abstract, final, static, inner, anonymous, local classes; organized by scope and instantiation rules.
Where the initialization of static/non-static fields is allowed
Static fields: class definition, static blocks. Non-static fields: instance creation, constructors, instance initializers.
What is the difference between a member of a class copy and a static class member
Instance member: separate copy per object, accessed via instance. Static member: shared across all instances, accessed via class name.
Is it possible to declare the method abstract and static at the same time
No, method cannot be both abstract and static; abstract requires overriding in subclass, static cannot be overridden.
How to access overstroting parental methods
Call parent method using super keyword: super.methodName() inside child class, allowing access to overridden parent implementation.
Is it possible to override the access level/type of the returned value when the method is private
No, you cannot override access level or return type if original method is private; private methods are not inherited so overriding concept doesn't apply,it's method shadowing instead.
Can non -non -static methods can overload static
No, non-static methods cannot overload static methods; static methods are resolved at compile-time by class reference while instance methods are resolved at runtime by object reference,different resolution strategies prevent overloading.
What an exception is released when an error occurs in the class initialization unit
ExceptionInInitializerError is thrown when an exception occurs in static initialization block or class variable initialization; it wraps the actual exception as cause.
What will happen if an exception throws in the constuctor
If exception is thrown in constructor, object creation fails and instance is never created; the exception propagates to caller, and object reference remains uninitialized.
Why Java uses static initialization blocks
Static initialization blocks execute once when class is loaded, used for complex static variable initialization, logging setup, or resource initialization that cannot be done inline.
What designs Java are applicable to the Static modifier
Singleton (default instance per container), Prototype (new instance per request), Request (per HTTP request), Session (per user session), and Application (per ServletContext) are main scope designs using static modifier.
What is the procedure for calling constructors and blocks of initialization taking into account the hierarchy of classes
Initialization order: parent static blocks → child static blocks → parent instance blocks → parent constructor → child instance blocks → child constructor. Each level completes before the next begins.
Can an object gain access to a Private-cross-class class, if, yes, then how
Yes, via inner classes,a private inner class can be accessed by outer class and sibling inner classes; also through reflection using setAccessible(true) on private members.
That has a higher level of abstraction - class, abstract class or interface
Interface has highest abstraction level, followed by abstract class, then concrete class; interfaces define contracts only, abstract classes provide partial implementation.
Why is it impossible to declare the interface method with the Final modifier
Interface methods cannot be final because interfaces define contracts that implementations must override; final would prevent method overriding, violating interface semantics.
Why in some interfaces do not determine the methods at all
Marker interfaces (like Serializable, Cloneable) contain no methods to tag classes with metadata or signal capabilities to the JVM without requiring implementations.
In what cases should the abstract class should be used, and in which interface
Use abstract classes for shared code and state between related classes; use interfaces for defining contracts across unrelated classes or multiple inheritance scenarios.
What modifiers by default have fields and interfaces methods
Interface fields are implicitly public static final; interface methods are implicitly public abstract (pre-Java 8; Java 8+ allows default/static methods).
Where and for what the ABSTRACT modifier is used
Abstract modifier is used on classes (can't instantiate, defines contracts) and methods (no implementation, must override), forcing subclasses to provide concrete implementations.
In what cases should the abstract class should be used, and in which interface
Use abstract classes for shared state/code with access control, constructors, and non-public members; use interfaces for pure contracts and multiple inheritance of type.
What modifiers by default have fields and interfaces methods
Interface methods default to public abstract (pre-Java 8) or public (with body in Java 8+); interface fields default to public static final.
Where and for what the ABSTRACT modifier is used
ABSTRACT modifier declares a class/method that cannot be instantiated/invoked directly; abstract classes provide partial implementations, abstract methods force subclasses to override them.
What beaten operations do you know
Atomic operations are indivisible, uninterruptible actions; examples: volatile reads/writes, compare-and-swap (CAS), atomic variable operations (AtomicInteger, AtomicReference).
What is a thornsary choice operator
Ternary operator syntax is condition ? valueIfTrue : valueIfFalse; returns one of two values based on a boolean condition, providing concise inline conditional assignment.
What logical operations and operators know
Logical operators: && (AND, short-circuit), || (OR, short-circuit), ! (NOT); bitwise operators: & (AND), | (OR), ^ (XOR), ~ (NOT) operate on bit level.
What do you know about the function of Main ()
Main() is the static entry point JVM invokes to start the application; it accepts String[] args for command-line arguments and must be public static void.
What values are initialized by default variables
Primitive types initialize to 0/0.0/false (int, long, float, double, boolean); object references initialize to null; local variables have no default and must be explicitly initialized.
What are the exceptions
Exceptions are objects representing error conditions that disrupt program flow; they're organized in a hierarchy with checked exceptions (must be caught/declared) and unchecked exceptions (RuntimeException subclasses) that don't require explicit handling.
What is and how the cloning of objects, arrays and two -dimensional arrays is used
Cloning creates shallow or deep copies of objects using clone() method or copy constructors; for arrays, use System.arraycopy() or clone(), and for 2D arrays, iterate through rows since clone() creates a shallow copy of the reference array.
What is autoboxing
Autoboxing is automatic conversion between primitive types and their wrapper classes (e.g., int to Integer); introduced in Java 5 to simplify code and allow primitives in generic collections.
What is an initialization block
An initialization block is a code block executed before constructors, with instance blocks running for each object creation and static blocks running once when the class loads; useful for complex object setup.
What are "anonymous classes" where they are used
Anonymous classes are unnamed inner classes implementing interfaces or extending classes; used for quick single-use implementations like event listeners.
Is it true that primitive data types are always stored in the stack, and specimens of reference data types in a heap
False; primitive types are stack-allocated but reference type variables (references) are on stack while objects are on heap.
Tell me about the type of type, what is a decrease and increase in type
Type casting: upcasting (subclass to superclass, safe, implicit) and downcasting (superclass to subclass, unsafe, requires explicit cast with runtime check).
Когда в приложении может быть выброшено исключение ClassCastException
ClassCastException is thrown when explicitly casting an object to an incompatible type that isn't assignable; for example, casting a String to Integer or a parent class reference to an unrelated child class.
What are literals
Literals are fixed values written directly in code; they include numeric (42, 3.14), string ("hello"), boolean (true), character ('a'), and null literals.
Why string is an unchanged and finalized class
String is final and immutable for security (password/token safety), performance (hash caching), and thread-safety; it allows String interning and safe sharing across threads without synchronization.
Why Char [] is preferable to string for storing password
Char[] is preferable to String for passwords because String remains in memory as an immutable object and can be read from heap dumps; Char[] can be explicitly cleared (Arrays.fill) after use.
Why a line is a popular key in Hashmap in Java
String is a popular HashMap key because it's immutable (hashCode never changes), thread-safe, and its hashCode is cached, making lookups O(1) with no unexpected collisions.
Is it possible to use lines in the design of Switch
Yes, since Java 7+ you can use Strings in switch statements; the compiler converts them to hashCode comparisons, making it efficient and cleaner than if-else chains.
Why is the Clone () method announced in the Object class, and not in the Cloneable interface
clone() is in Object class not Cloneable because Cloneable is a marker interface with no methods; clone() requires deep knowledge of the object's state, so Object provides the default shallow copy implementation.
What is the "default constructor"
A default constructor is a no-argument constructor provided by the compiler if you don't define any constructor; it initializes fields to default values (null for objects, 0 for primitives).
How the constructors differ by defending, copying and constructor with parameters
Default constructor initializes fields to defaults; copy constructor takes an instance and copies its fields; parameterized constructor accepts specific values to initialize fields explicitly.
Where and how you can use a closed constructor
Private constructors prevent instantiation from outside; used in singleton pattern (private constructor + static getInstance()), utility classes (Math, Collections), and factory methods.
Tell me about the classes-loaders and about dynamic class loading
ClassLoaders load Java classes into memory; JVM uses three: Bootstrap (JDK classes), Extension (optional packages), and Application (user classes); dynamic loading uses Class.forName() or ClassLoader.loadClass().
Equals () gives rise to the ratio of equivalence, what properties does this attitude have
Equals() must be reflexive (x.equals(x)==true), symmetric (x.equals(y)==y.equals(x)), transitive (x.equals(y) && y.equals(z) implies x.equals(z)), and consistent across calls.
How are Hashcode () and Equals () methods in class Objecte implemented
Default hashCode() returns object identity hash; default equals() compares references; override both together,objects equal by equals() must return same hashCode().
Are there any recommendations about which fields should be used when counting Hashcode ()
Use immutable fields (final primitives, Strings, immutable objects) for hashCode() to ensure consistency; avoid mutable fields that change after object creation, and exclude fields used in equals().
Which operator allows you to force the exception
The 'throw' operator explicitly throws an exception; syntax: throw new ExceptionType("message");
What is the keyword of Throws talking about
The 'throws' keyword declares that a method can throw checked exceptions, delegating handling to the caller; it's part of the method signature.
How to write your own ("user") exception
Create a custom exception by extending Exception (checked) or RuntimeException (unchecked); override constructors and optionally add custom fields/methods for additional context.
What are the Unchered Exception
Unchecked exceptions (RuntimeException subclasses) don't require explicit catching/declaring; they occur at runtime (NullPointerException, IllegalArgumentException, ArithmeticException) and are often programming errors.
What is Error
Error is a serious JVM problem (OutOfMemoryError, StackOverflowError) indicating the application shouldn't catch it; errors are unchecked and typically unrecoverable.
Can one Catch block catch several exceptions at once
Yes, since Java 7 you can catch multiple exceptions in one block using pipe syntax: catch (IOException | SQLException e) { }; they're treated as a single variable of their common type.
Is Finally a block always executed
Finally block executes in almost all cases, but won't complete if JVM terminates (System.exit(), fatal error), thread is killed, or an infinite loop occurs in try/catch.
Are there any situations when the Finally block is not completed
Finally block fails to complete if System.exit() is called, JVM crashes, thread is forcibly terminated, or infinite loop occurs in try/catch block.
Can the Main method throw out the exclusion outside and if so, then where the processing of this exception will occur
Yes, main() can throw checked exceptions by declaring throws clause; JVM catches it and prints stack trace to System.err, then terminates.
What is "Internationalization"
Internationalization (i18n) is designing applications to support multiple languages and regions without code changes, using ResourceBundles and locale-aware formatting.
What is "localization"
Localization (l10n) is the process of translating and adapting an i18n-ready application to a specific language/region with translated resources.
Differences of Softreference from Weakreference
SoftReference is released when memory is needed; WeakReference is released during garbage collection regardless of memory pressure; SoftReference retains data longer.
How to write immutable grade
Use private final fields, initialize all fields in constructor, no setters, make class final, and return defensive copies or immutable objects from getters.
Intermediate operations in Stream API
Intermediate operations are lazy-evaluated methods like filter(), map(), flatMap(), distinct(), sorted(), limit(), skip() that return Stream and enable chaining.
The life cycle of the Servtov
Servlet lifecycle: init() → service() (which calls doGet/doPost/etc.) → destroy(); container manages instantiation, processing requests, and cleanup.
What is Default Method on Interface
Default methods are concrete implementations in interfaces introduced in Java 8, allowing interfaces to provide method bodies without breaking implementing classes.
Using the InstanceOF operator
instanceof checks if an object is an instance of a class or subclass; returns boolean; used before casting to avoid ClassCastException.
Is adding always to ArrayList the complexity O (1)
No, ArrayList add() is O(1) amortized but O(n) when capacity is exceeded and array resizing occurs; capacity grows by 50% when threshold is reached.
Did generics always exist in Java
No, generics were introduced in Java 5; before that, collections used Object type without compile-time type safety.
What is WildCarts
Wildcards are ? in generics allowing flexible method signatures: ? unbounded, ? extends X upper bound, ? super X lower bound for covariance/contravariance.
Knowing the answers is half the battle
The other half is explaining them clearly under pressure.
Try a free mock interviewarrow_forward