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.
There are following errors in the program:
1. Line number: 1
Error Description: Random is a class in java.util package.
Statement after correction: import java.util.Random;
2. Line number: 4
Error Description: Missing {
Statement after correction: {
3. Line number: 11
Error Description: skip is a function.
Statement after correction: skip();
4. Line number: 20
Error Description: invalid method declaration.
Statement after correction: public int getStand()
5. Error: main function is missing in the class.
Statement after correction: public static void main(String args[]){}
Get Answers For Free
Most questions answered within 1 hours.