Understand Java SE 25 parameter passing, constant variables and thread states, Jakarta Pages scopes, and the purpose of legacy LookupDispatchAction.
Answer: A final variable cannot be reassigned after its permitted initialization. For a reference variable, that freezes the reference, not the referenced object. A final List can still be mutable, and an object reached through a final field can contain changing state.
A blank final field can be initialized by constructors under definite-assignment rules. Final, immutable, and compile-time constant are different concepts.
Answer: Page scope belongs to the current page context; request scope follows the request; session scope spans requests in a session; application scope belongs to the servlet context. They are attribute scopes, not Java local-variable scopes. Tomcat 11 implements Jakarta Pages 4.0.
PageContext exposes the scope constants and attribute operations. Request attributes can survive a forward within the request, while session and application attributes may be accessed concurrently. A page with sessions disabled cannot use session scope as though a session were available.
Answer: An object is a class instance or an array. It has identity and a runtime type, and may have state. References let code access objects; several references can refer to the same object. A variable of a reference type is not itself the object it refers to.
Answer: A class declaration defines a reference type and its members, including fields, methods, and constructors. Objects instantiated from it have their own instance state, while static fields belong to the class. Abstract classes cannot be directly instantiated but can contribute behavior and state to subclasses.
Answer: Java always passes argument values. For an object argument, that value is a reference, so the callee can mutate the same object but cannot replace the caller's variable by reassigning its parameter. Primitive parameters receive copies of primitive values.
public class ArgumentCopies {
static final class Box { int value = 1; }
static void change(Box box, int number) {
box.value = 2;
box = new Box();
box.value = 3;
number = 9;
}
public static void main(String[] args) {
Box box = new Box();
int number = 5;
change(box, number);
System.out.println(box.value);
System.out.println(number);
}
}
Answer: Thread.sleep and Thread.yield are examples. Sleep pauses the current thread subject to timing and interruption rules; yield is only a scheduling hint. Neither should be called through another thread reference as though it controls that other thread, and neither is a substitute for synchronization.
Answer: Thread.State defines BLOCKED for waiting to enter a monitor, WAITING for an indefinite wait such as untimed wait or join, and TIMED_WAITING for timed waiting such as sleep. NEW and TERMINATED also are not runnable. The complete set has six states, including RUNNABLE.
There is no SLEEPING enum constant. RUNNABLE covers both execution and eligibility for execution; it does not mean a thread has a processor at that exact instant.
Answer: It must be final, have primitive or String type, and be initialized with a constant expression. Static is not required. A final reference to an ArrayList is not a constant variable, and a static final value computed by a method call is not necessarily one.
For example, final int limit = 10; can be a constant variable, while static final int limit = Integer.parseInt("10"); is not.
Answer: The implementation must be public; it cannot reduce access. An abstract class may leave the method unimplemented, and a concrete class can inherit a suitable implementation. This applies to public abstract instance methods, not to private interface helpers or static methods that are not implemented through instance dispatch.
Answer: It routed a request to an action method using a localized submitted value. It used message resources to recover a resource key and a getKeyMethodMap mapping to choose the corresponding method. This supported forms with several localized submit buttons.
It belongs to the retired Struts 1 framework, not Java SE or current Jakarta Servlet. Modern applications should define routing explicitly using a supported framework rather than adopting this legacy class.
References: Java SE 25 Language Specification, Jakarta Pages 4.0, Thread.State, Struts 1 end-of-life notice, Legacy action dispatch strategies.