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
finlep [7]
3 years ago
12

Polymorphism occurs when subclasses override the behavior from the superclass. structure TRUE FALSE

Computers and Technology
1 answer:
insens350 [35]3 years ago
7 0

Answer:

The correct answer for the given question is true.

Explanation:

When a subclass override the method from superclass then this is known as Method overriding.

Method override is an Runtime polymorphism.

In the method overriding both superclass and subclass method are identical having same name and same parameter.

Example

class abc

{  

 void sum()

{

System.out.println("class abc ");}  

}  

class abc1 extends abc

{  

 void sum() // override the method sum

{

System.out.println("class abc1");

}  

public static void main(String args[]) // main method

{  

   abc ob = new abc1();//upcasting  

   ob.sum();    // calling function sum()

 }  

}  

Output

class abc1

In this both class abc and abc1  have same method i.e sum after that we create reference variable in main method of class ob which refers the subclass object and using this reference variable it call the method sum.

You might be interested in
How can I collect tweets from different accounts concurrently and categorize the tweets in a corpus?
jenyasd209 [6]
Take screenshots of other tweets and get a app that can put them together in 1 photo or use google slides
4 0
3 years ago
An undesirable jagged appearance is referred to as
Papessa [141]

What do we have to answer spectificly

7 0
3 years ago
Read 2 more answers
Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
kakasveta [241]

Answer:

(1)

public int getPlayer2Move(int round)

{

  int result = 0;

 

  //If round is divided by 3

  if(round%3 == 0) {

      result= 3;

  }

  //if round is not divided by 3 and is divided by 2

  else if(round%3 != 0 && round%2 == 0) {

      result = 2;

  }

  //if round is not divided by 3 or 2

  else {

      result = 1;

  }

 

  return result;

}

(2)

public void playGame()

{

 

  //Initializing player 1 coins

  int player1Coins = startingCoins;

 

  //Initializing player 2 coins

  int player2Coins = startingCoins;

 

 

  for ( int round = 1 ; round <= maxRounds ; round++) {

     

      //if the player 1 or player 2 coins are less than 3

      if(player1Coins < 3 || player2Coins < 3) {

          break;

      }

     

      //The number of coins player 1 spends

      int player1Spends = getPlayer1Move();

     

      //The number of coins player 2 spends

      int player2Spends = getPlayer2Move(round);

     

      //Remaining coins of player 1

      player1Coins -= player1Spends;

     

      //Remaining coins of player 2

      player2Coins -= player2Spends;

     

      //If player 2 spends the same number of coins as player 2 spends

      if ( player1Spends == player2Spends) {

          player2Coins += 1;

          continue;

      }

     

      //positive difference between the number of coins spent by the two players

      int difference = Math.abs(player1Spends - player2Spends) ;

     

      //if difference is 1

      if( difference == 1) {

          player2Coins += 1;

          continue;

      }

     

      //If difference is 2

      if(difference == 2) {

          player1Coins += 2;

          continue;

      }

     

     

  }

 

  // At the end of the game

  //If player 1 coins is equal to player two coins

  if(player1Coins == player2Coins) {

      System.out.println("tie game");

  }

  //If player 1 coins are greater than player 2 coins

  else if(player1Coins > player2Coins) {

      System.out.println("player 1 wins");

  }

  //If player 2 coins is grater than player 2 coins

  else if(player1Coins < player2Coins) {

      System.out.println("player 2 wins");

  }

}

3 0
3 years ago
Write any two use of computer in school​
igomit [66]

Answer:

To solve mathmatical problem

To make questions paper

7 0
3 years ago
Write a program that uses two input statements to get two words as input. Then, print the words on one line separated by a space
Shkiper50 [21]

word1 = input("Enter a word: ")

word2 = input("Enter a word: ")

print(word1 + " " + word2)

I hope this helps!

6 0
3 years ago
Other questions:
  • Which sentence best describes an activity stream?
    10·2 answers
  • What Software is used to play,create, and modify audio and video files
    7·2 answers
  • How do you calculate the total resistance in a series circuit with more than one resistor?
    9·1 answer
  • <img src="https://tex.z-dn.net/?f=6.372%20%5Ctimes%2075%20find%20the%20product" id="TexFormula1" title="6.372 \times 75 find the
    6·1 answer
  • What is a programming language?
    11·1 answer
  • From which type of data storage does the CPU load information for processing during normal operation?
    14·1 answer
  • What is the difference between = and == in terms of java..?
    6·2 answers
  • 2.
    8·1 answer
  • Please help!!! I am very confused about this question!
    10·1 answer
  • Hey guys, I don’t have a problem for you but If anyone knows do you still pass your grade level if you failed 1 class in the las
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!