- Create a class called Cricket
- Have below method in it. public int calculate(int balls) { return balls * 6; }
- Create one more class called 'Player1'
- Have main method in it.
- Now, create instance for 'Cricket' class.
- Using instance, call calculate() method with 10 as argument.
- Now, store the returned result as score.
- print the score.
public class Cricket {
public int calculate(int balls)
{
//System.out.println("gugan ball");
return balls * 6;
}
}
public class Player1 {
public static void main(String[] args) {
Cricket gugan = new Cricket();
int balls = gugan.calculate(10);
System.out.println(balls);
}
}
Top comments (0)