MODULE 3 (Week 4) Polymorphism Flashcards

1
Q

Describes situations in which something occurs in several different forms

Describes the concept that you can access objects of different types through the same interface. Each type
can provide its own independent implementation of this interface.

A

Polymorphism

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

Why is polymorphism used in Java?

A

It makes it possible to write a method that can correctly process different types of functionalities that have the same name

Consistency can be gained in a code by using polymorphism

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

Advantages of Polymorphism in Java

A

It provides reusability to the code.

A single variable can be used to store multiple data values.

With lesser lines of code, it becomes easier for the programmer to debug the code.

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

A class has multiple methods having the same name but different in parameters

A

Method Overloading

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

Where is method overloading performed?

A

Within a class

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

Three ways to overload methods in Java:

A

By changing number of arguments

By changing the data type

By changing both number of arguments and data type

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

A situation that occurs when the compiler cannot determine which method to use

A

Ambiguous situations

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

Methods with identical names that have identical argument lists but different return types

A

Illegal methods

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

An object’s memory address

Is implicit - is automatically understood without actually being written

A

Reference

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

The reference to an object

Passed to any object’s non-static class method

A reserved word in Java

Does not need to be used in methods you write in most situations

Use to make classes work correctly

A

This reference

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

A this reference is implicitly received by what type of methods?

A

Instance methods

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

When a this referenced is used with a field name in a class method, the reference is to what?

A

To the class field instead of to the local variable declared within the method

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

In using static fields, this type of methods do not have the this reference and have no object associated with them

A

Class methods

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

In using static fields, this type of variables are shared by every instantiation of a class and only has one copy per class

A

Class variables

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