DEV Community

AmalaReegan
AmalaReegan

Posted on

Day7 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.
**

Input:

class Player { public static void main(String[] args) { Player dhoni=new Player(); int run=dhoni.battingball(30); System.out.println(run); } public int battingball(int run) { return 50+50; } } 
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Top comments (0)