Home > Java > javaTutorial > Player dhoni task

Player dhoni task

Linda Hamilton
Release: 2025-01-01 08:43:09
Original
500 people have browsed it

Player dhoni task

  1. Create a class Called Player
  2. Have main method in it.
  3. Inside main method, create an instance(object) called 'dhoni'.
  4. Using 'dhoni' reference, call a method called 'batting(30)'
  5. From batting, return 100
  6. Store returned value as score.
  7. Print returned value in main method.

package terminaltask;

public class Player {
public static void main(String[] args) {
Player dhoni = new Player();
int score = dhoni.batting(30);
System.out.println(score);

}
public int batting(int run)
{
return 100;
}
}
out put 100

The above is the detailed content of Player dhoni task. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template