chap 10 Flashcards
what is the difference between overriding and overloading?
Overloaded methods have the same name, they have different signatures. When a method overrides another method, however, they both have the same signature.
when does java perform dynamic binding?
Java performs dynamic binding or late binding when a variable contains a polymorphic reference. This means that the Java Virtual Machine determines at runtime which method to call, depending on the type of object that the variable references.
What is binding?
the process of matching a method call with the correct method definition is known as binding
In an inheritance relationship, what executes first? The subclass or superclass.
superclass.
Which shows the inheritance relationships among classes in a manner similar to that of a family tree?
class hierarchy
all fields declared in an interface _____
are treated as final and static
What is the difference between an abstract class and an interface.
Abstract class serves as a partially complete class, providing common functionality and leaving some methods abstract, to be implemented by its subclasses. Abstract classes can also provide method implementations that subclasses can use or override.
Interfaces focus solely on specifying a set of method signatures that implementing classes must adhere to. They do not contain any method implementations themselves; instead, they define a contract that implementing classes must fulfill.
In java, a reference variable is _____ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.
a) dynamic
b) polymorphic
c) static
d) public
b) polymorphic
True or false: a compiler error will result if an anonymous inner class tries to use a variable that is not final, or not effectively final.
True
In Java, if an anonymous inner class tries to use a local variable from its enclosing scope that is not declared as final or effectively final (meaning its value does not change after initialization), a compiler error will occur. This restriction ensures that the anonymous inner class can access the variable safely, even if it’s used outside the scope of the method where it’s defined.