1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
malfutka [58]
2 years ago
14

"The ability to create methods with the same name that are in different classes" is known as ________.

Computers and Technology
1 answer:
Jlenok [28]2 years ago
6 0

Answer:

Polymorphism

Explanation:

Polymorphism is the ability of an object to take multiple forms. It is an important concept of Object Oriented Programming. Polymorphism is used in Object Oriented Programming when a reference of a parent class is used to refer to a child class object. It allows to perform a single action in different ways. For example a person can possess different characteristics at the same time. A person can be a father, husband, employee or student. The same person can have different behaviors in different circumstances.

Example:

Suppose there is class Animal with a procedure sound(). This method can have different implementation for different animals. For this purpose lets take two derived classes Cow and Cat that extend the Animal class (parent/base class). Now the method sound() can be used in different ways for Cow and Cat.

public class Animal{

public void sound(){

System.out.println("Animal is making a sound");  } }

public class Cat extends Animal{

 public void sound(){

  System.out.println("Meow");     } }

The output is Meow. The same method sound() is used for cat subclass.

public class Cow extends Animal {

  public void sound(){

    cout<<"Mooo";  }}

The output is Mooo. The method sound() is used for a Cow subclass which returns the sound of Cow in output.

So the same function i.e. sound() behaves differently in different situations which shows Polymorphism.

Polymorphism has 2 types.

One is compile time polymorphism which is called overloading. In method overloading a class can have more than one functions with same name but different parameters. Methods can be overloaded by change in number or type arguments. For example overloading a function method() can take the following forms in which the name remains the same and parameters are different.

void method(int a)

void method(float a)

void method(float a, float b)

Second type is run time polymorphism which is called overriding. Method overriding is when a method declared in derived class is already present in base class. In this way derived/child class can give its own implementation to base/parent class method. Method present in base class is called overridden and that in subclass is called overriding method. The example of Animal Cow and Cat given above is an example of overriding.

You might be interested in
Write a program that prints the following 45 pairs of numbers:
sattari [20]

Answer:

  • Code is in JAVA language. As there is no user input the logic is straightforward.
  • Below is the code along with a detailed explanation of the logic.
  • The class name is Print main save as file as the main class.

Explanation:

Program:-

public class Main{

public static void main(String args[]){

/* There are two for loops...

* First for loop runs from i=1 to i=9

* Second for loop runs from j=1 to j=i.

*

*/

for(int i=1;i<=9;i++){

for(int j=1;j<=i;j++){ // j loop runs from j=1 to j=i

/*Prints I and j next to each other*/

System.out.println(i+""+j);

}//for loop of j ends here

}// for loop of I ends here

}

}

6 0
2 years ago
A raised dot (ú) shows where the enter key was pressed. true or false.
Yakvenalex [24]
False i doesnt  shows anything like this


6 0
3 years ago
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space.
Ksenya-84 [330]

Answer:

   while(userNum>=1){

       System.out.print(userNum/2+" ");

       userNum--;

        }

Explanation:

This is implemented in Java programming language. Below is a complete code which prompts a user for the number, receives and stores this number in the variable userNum.

<em>import java.util.Scanner;</em>

<em>public class TestClock {</em>

<em>    public static void main(String[] args) {</em>

<em>    Scanner in = new Scanner (System.in);</em>

<em>        System.out.println("Enter the number");</em>

<em>    int userNum = in.nextInt();</em>

<em>    while(userNum>=1){</em>

<em>        System.out.print(userNum/2+" ");</em>

<em>        userNum--;</em>

<em>         }</em>

<em>    }</em>

<em>}</em>

The condition for the while statement is userNum>=1 and after each iteration we subtract 1 from the value of   userNum until reaching 1 (Hence userNum>=1)

3 0
3 years ago
Write a function named partfthat takes inas parameterstwo parallel lists: a list of times (in increasing order), and a list of d
mario62 [17]

The program calculates the velocity between points in a list is written below. The program is written in python 3 thus ;

t = input("Enter time values : ")

<em>#Enter</em><em> </em><em>the</em><em> </em><em>time</em><em> </em><em>values</em><em> </em><em>of</em><em> </em><em>the</em><em> </em><em>data</em>

p = input("Enter distance values : ")

<em>#Enter</em><em> </em><em>the</em><em> </em><em>distance</em><em> </em><em>values</em>

dist = [float(x) for x in p.split()]

time = [float(x) for x in t.split()]

<em>#pyt</em><em> </em><em>then</em><em> </em><em>values</em><em> </em><em>in</em><em> </em><em>a</em><em> </em><em>list</em><em> </em>

def partfthat(dist, time):

<em>#initialize</em><em> </em><em>function</em><em> </em><em>that</em><em> </em><em>takes</em><em> </em><em>in</em><em> </em><em>two</em><em> </em><em>parameters</em><em> </em>

vel = []

<em>#empty</em><em> </em><em>list</em><em> </em><em>to</em><em> </em><em>hold</em><em> </em><em>the</em><em> </em><em>calculated</em><em> </em><em>velocity</em><em> </em><em>values</em><em> </em>

i = 0

<em>#indexer</em><em> </em>

while i <= len(dist)-2:

<em>#while</em><em> </em><em>loop</em><em> </em><em>to</em><em> </em><em>iterate</em><em> </em>

v = (dist[i+1] - dist[i]) / (time[i+1] -time[i])

<em>#</em><em>Use</em><em> </em><em>the</em><em> </em><em>velocity</em><em> </em><em>formula</em><em> </em>

vel.append(v)

<em>#append</em><em> </em><em>values</em><em> </em><em>to</em><em> </em><em>the</em><em> </em><em>empty list</em><em> </em><em>created</em><em> </em>

i+=1

return vel

print(avg_vel(dist, time))

<em>A</em><em> </em><em>sample</em><em> </em><em>run</em><em> </em><em>of</em><em> </em><em>the</em><em> </em><em>program</em><em> </em><em>is</em><em> </em><em>attached</em><em>.</em><em> </em>

Learn more : brainly.com/question/25681441

4 0
2 years ago
How to resize an image in photoshop without losing quality.
castortr0y [4]

Answer:

Explanation:

Make sure resample is turned on

Turn on the chain link if you want the width and height to change together. If not, turn off the chain so that you can set your own width and height.

Choose your new size (you can choose to choose different measurement units by clicking on “inches”)

press ok

i hoped this helped!!!!!!!!

8 0
2 years ago
Other questions:
  • Write a function `has_more_zs` to determine which of two strings contains # more instances of the letter "z". It should take as
    9·1 answer
  • Which of the following is an example of a problem that could be attributed to poor ergonomics?
    10·1 answer
  • What type of topology gives you a direct connection between two routers so that there is one communication path?
    14·1 answer
  • Programming Using OOJAVA<br> check this Atterchment and solve Exascies 1, 2, and 3
    10·1 answer
  • Csc105 final graded project
    9·1 answer
  • What was the process called that required the photographer to have a tent or darkroom handy so that chemicals could be mixed qui
    7·1 answer
  • You are working with an online tech service to fix a problem with installation of a program on your machine. You grant them remo
    13·1 answer
  • Question is on the picture thank you
    10·1 answer
  • Question 1 (1 point)
    8·1 answer
  • 1. Fill in the blanks with appropriate word. 5°1-5 is a collection of raw unprocessed facts, figures, and symbols ​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!