23.9k views
0 votes
Using an object for multi-purpose in Java is called:

a) Inheritance
b) Encapsulation
c) Polymorphism
d) Abstraction

1 Answer

4 votes

Final answer:

Polymorphism is the concept in Java that allows an object to be used for multiple purposes.

Step-by-step explanation:

The object-oriented concept in Java that allows an object to be used for multiple purposes is called polymorphism.

Polymorphism means that an object can take different forms or types. In Java, this is achieved through method overloading and method overriding.

For example, let's say you have a superclass called Shape and two subclasses called Circle and Rectangle. You can create an array of Shape objects and store both Circle and Rectangle objects in it. Then, you can use a for loop to iterate through the array and call a common method, such as calculateArea(), which will be overridden by the Circle and Rectangle classes to provide different implementations.

User Askielboe
by
7.7k points