In: Computer Science
Identify errors and correct them of the following Java program:
1. import java.utility.Random;
2.
3. public class Sequen
4.
5. private int stand
6. private int calc;
7.
8. public Sequen(int numStand)
9. {
10. stand = numStand;
11. skip;
12. }
13.
14. public void skip()
15. {
16. Random sit = new Random();
17. calc = sit.nextInt(stand) + 1;
18. }
19.
20. public getStand()
21. {
22. return stand;
23. }
24.
25. int getCalc()
26. {
27. return calc;
28. }
29. }
One error is already identified for you as shown below:
Line Number: 5
Error description: Missing semicolon
Statement after correction: private int stand;
Identify 5 other errors and give their Line Number, Error description and Statement after correction.
answer within 30 mins
ERROR-1
Line-1
Error Description- Random class not defined properly. 'utility' is used in case of 'util'.
Statement after correction- import java.util.Random;
===========================================
ERROR-2
Line-3
Error Description- class initializing curly brace '{' missing. It should be used after defining the class name.
Statement after correction- public class Sequen{
===========================================
ERROR-3
Line-5
Error Description- statement is not ended that is semi colon ';' is not used at the end of the statement.
Statement after correction- private int stand;
===========================================
ERROR-4
Line-11
Error Description- skip() function is not called with the right syntax, parathesis not used after function name.
Statement after correction- skip();
===========================================
ERROR-5
Line-20
Error Description- return type is not defined for for the function 'getstand()' and this fucntion returns int data type value so the return type of this function should be int data type.
Statement after correction- public int getStand()
===========================================