- Create a class Called Player
- Have main method in it.
- Inside main method, create an instance(object) called 'dhoni'.
- Using 'dhoni' reference, call a method called 'batting(30)'
- From batting, return 100
- Store returned value as score.
- 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
Top comments (0)