Java Object-Oriented Approach
The exam probes encapsulation, inheritance mechanics, interface evolution and the exact order in which objects are initialized.
Encapsulation and inheritance
Access goes private, package-private (no modifier), protected, public. Protected means package plus subclasses, and in another package you can only touch the member through a subclass reference. A constructor may call this(...) or super(...), but only as its first statement; if neither appears the compiler inserts super().
Initialization order: static fields and static blocks once at class initialization; then, per object, the superclass constructor completes, then instance field initializers and instance initializer blocks in textual order, then the constructor body.
Abstract classes and interfaces
An abstract class may have constructors, fields and concrete methods, but cannot be instantiated or marked final. Interface methods are implicitly public abstract unless they are default, static, or private (Java 9+); interface fields are public static final. A class can implement several interfaces; if two unrelated interfaces provide conflicting defaults the class must override, and it can call Interface.super.method().
Overriding rules
The return type may be covariant, visibility cannot be reduced, and no new or broader checked exception may be declared. Static methods are hidden, private methods are not overridden, and overload selection happens at compile time based on the declared reference type while overriding dispatches at runtime on the actual type.
Worked example
class A { A() { show(); } void show() { System.out.print("A"); } } class B extends A { int n = 5; void show() { System.out.print(n); } } with new B(); prints 0, not 5: A's constructor runs before B's field initializers, so the overridden method sees the default value.
Traps
Calling overridable methods from constructors; overriding equals without hashCode; assuming final on a reference prevents mutation of the object; confusing hiding with overriding.