chap 10 Flashcards

1
Q

what is the difference between overriding and overloading?

A

Overloaded methods have the same name, they have different signatures. When a method overrides another method, however, they both have the same signature.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

when does java perform dynamic binding?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is binding?

A

the process of matching a method call with the correct method definition is known as binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In an inheritance relationship, what executes first? The subclass or superclass.

A

superclass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which shows the inheritance relationships among classes in a manner similar to that of a family tree?

A

class hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

all fields declared in an interface _____

A

are treated as final and static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between an abstract class and an interface.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

b) polymorphic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly