Frage im Vorstellungsgespräch bei FJA-US

overriding vs. overloading, Interface vs. Abstract, .equals() vs. ==, static vs. final

Antwort im Vorstellungsgespräch

Anonym

13. Jan. 2011

Overriding - two methods with the same name, but different input parameters Overloading - child class has same signature (method name and parameters) as parent class; the parent method's functionality is overridden by the child method's. Abstract methods do not have implementation, and should be implemented in child classes. All classes that implement an interface MUST override each method in the interface. == compares references in memory (only use with simple structures like ints), .equals compares the values contained in the objects (use with Strings). The static keyword is used to define constants, or methods that use no instance variables. Final variables cannot change, final classes cannot be extended, and final methods cannot be overridden. Static methods are also final, but static variables can be changed; however, There Can Be Only One of a static variable throughout all instances of a class.