Distinguish class state from instance state, implicit constructor calls, shared counters, and Java 25 instance main methods.
Answer: An ordinary class gets a compiler-provided default constructor only when it declares no constructors. Declaring any constructor suppresses that default.
A no-argument constructor may still exist if you explicitly write one. Specialized class forms, including records and enums, have additional rules; do not generalize the ordinary-class default to every class declaration.
Answer: An ordinary constructor other than Object's implicitly invokes super() when its body contains no explicit this(...) or super(...) constructor invocation. If it delegates with this, that other constructor is responsible for continuing the chain.
The implicit no-argument call must be legal. It does not synthesize a missing parent constructor. An explicit Java 25 constructor invocation can follow a restricted prologue, but leaving it out does not delay implicit superclass construction until after the body statements.
Answer: A static method belongs to a class and has no implicit receiver object. It is useful for operations naturally expressed through explicit arguments or class-level responsibilities, such as a conversion utility or factory.
Static does not guarantee purity: the method can mutate static state or operate on objects passed as arguments. Choose it based on the API's responsibilities, not on the false assumption that a static method cannot interact with any instance.
Answer: Yes, if the program updates it at a clearly defined construction point. A counter incremented in a constructor measures those increments, not automatically the number of currently live objects. Delegating constructors and failed construction can complicate what is counted.
Concurrent construction needs synchronization or an atomic counter. Static state is per class identity, including the defining loader, so it is not necessarily one global counter for every similarly named class in the JVM.
Answer: They receive the same type-based defaults as instance fields: numeric zero, false for boolean, the zero code unit for char, and null for references. Static field storage is prepared as part of class linking, before ordinary explicit static initializers run.
Constant variables have additional initialization rules. A field initializer can replace the default with the intended value; local variables do not get this automatic default initialization before use.
Answer: For a simple concurrent increment, a private static final AtomicLong and incrementAndGet() provide an atomic operation. A plain count++, even on a volatile field, is a read-modify-write sequence and is not automatically atomic.
The application still needs to define what the count means, how overflow is handled, and when it is read. Atomic increment does not make an unrelated multi-field invariant atomic. For such an invariant, a shared lock or another coordinated design may be required.
Answer: No in Java SE 25. The traditional public static void main(String[] args) remains valid, but Java 25 also supports eligible instance main methods and no-argument main methods without preview flags.
public class InstanceEntry {
private final String greeting = "Hello from an instance";
void main() {
System.out.println(greeting);
}
}
Compile InstanceEntry.java with JDK 25 and run java InstanceEntry. It prints Hello from an instance. The launcher creates the instance using the eligible no-argument construction path before invoking this instance main method.
Answer: It has no implicit this receiver. The issue is not whether objects have already been created elsewhere; even if many objects exist, the static method does not automatically know which one should receive the call.
It can receive or create an object and call a method through that reference, such as worker.run(). Access restrictions and null checks still apply. An instance main method, unlike a static main method, has a receiver.
Answer: Static members belong to the declaring class; instance fields belong to individual objects and instance methods run with an object receiver. Use class-name qualification for static access and an object expression for instance access.
A static final reference can still point to a mutable shared object. An instance method can access static members, and a static method can use explicit object references. The distinction concerns ownership and receivers, not a total separation between two worlds.
Answer: It can be invoked without constructing an instance of the initial class, preserving the familiar entry-point convention. The class still undergoes initialization before main is invoked.
Instance main is an additional supported option. Eligible main methods return void, have either no parameters or a String array parameter, and have non-private access. When both candidate forms are available, the String-array form is preferred. Instance launch also requires a valid no-argument instance-creation path. Use the traditional form when compatibility with older Java versions or tools matters.
References: JLS: startup and initialization, JLS: static members and constructors, and AtomicLong API.