This Java SE 25 interview review covers several core language and API topics:
static methods, standard I/O streams, nested classes, RandomAccessFile,
the Singleton design pattern, interfaces, abstract classes, class variables, and
generic wildcards. These topics are frequently tested because they reveal whether
a developer understands the difference between class-level behavior, object-level
behavior, stream-based input/output, and type-safe API design.
static method belongs to the class rather than to an individual
object. It can be called by using the class name, and it cannot directly access
instance variables or instance methods unless it has an object reference.
Static methods are commonly used for utility behavior, factory methods, and
operations that do not depend on per-object state.
public class MathDemo {
public static int square(int value) {
return value * value;
}
public static void main(String[] args) {
int result = MathDemo.square(5);
System.out.println(result);
}
}
System.in, System.out, and System.err?
System.in is an InputStream, which is a byte input
stream. System.out and System.err are
PrintStream objects, which write output to byte-oriented streams
while providing convenient methods such as print,
println, and printf.
System.out.println("Standard output");
System.err.println("Error output");
public class OuterClass {
private String message = "Outer instance state";
static class StaticNestedClass {
void print() {
System.out.println("Static nested class");
}
}
class InnerClass {
void print() {
System.out.println(message);
}
}
}
java.io.RandomAccessFile implement?
java.io.RandomAccessFile implements
DataInput, DataOutput, and Closeable.
It can read and write primitive Java values and strings at specific positions
in a file by using a file pointer.
import java.io.RandomAccessFile;
public class RandomAccessFileDemo {
public static void main(String[] args) throws Exception {
try (RandomAccessFile file = new RandomAccessFile("example.dat", "rw")) {
file.writeInt(25);
file.seek(0);
int value = file.readInt();
System.out.println(value);
}
}
}
enum Singleton because it is concise, thread-safe, and
resistant to common serialization issues.
public enum ApplicationConfig {
INSTANCE;
public String getEnvironmentName() {
return "production";
}
}
The Singleton pattern should be used carefully. It can be useful for shared configuration or stateless services, but overuse can introduce hidden global state and make testing more difficult.
More on the Singleton Design Pattern can be found at gofpattern.com.
Comparable,
Runnable, AutoCloseable, or application-specific
service contracts.
interface ReportExporter {
void export(String fileName);
}
abstract class BaseReport {
private final String title;
protected BaseReport(String title) {
this.title = title;
}
public String title() {
return title;
}
public abstract void print();
}
static modifier.
There is one shared copy of the variable associated with the class, regardless
of how many objects are created from that class.
public class Counter {
private static int objectCount = 0;
public Counter() {
objectCount++;
}
public static int getObjectCount() {
return objectCount;
}
}
? extends T is commonly used when a method reads
values from a producer, and ? super T is commonly used when a
method writes values to a consumer.
import java.util.List;
public class WildcardDemo {
public static double sumNumbers(List<? extends Number> numbers) {
double total = 0.0;
for (Number number : numbers) {
total += number.doubleValue();
}
return total;
}
}
import java.util.List;
public class CopyDemo {
public static <T> void copyTo(List<? super T> destination,
List<? extends T> source) {
for (T item : source) {
destination.add(item);
}
}
}
This version uses wildcards to express the producer-consumer relationship:
the source produces values of type T, and the destination consumes
values of type T.
Collection have?
Collection interface has one type parameter:
Collection<E>, where E represents the element
type. By contrast, Map<K,V> has two type parameters:
K for the key type and V for the value type.
import java.util.Collection;
import java.util.List;
import java.util.Map;
Collection<String> names = List.of("Ada", "Grace", "James");
Map<Integer, String> users = Map.of(1, "Ada", 2, "Grace");
These questions remain useful for Java SE 25 because they connect foundational language rules with practical API usage. A modern Java developer should understand how static members differ from instance members, how nested classes are organized, how byte streams and file APIs work, and how generics improve type safety without sacrificing API flexibility.