find the errors in the code and rewrite it. give reasons as to why it is wrong( 6 marks)
Attachments:
Answers
Answered by
0
Answer:
The errors in the program are:-
1)class const
const is a keyword and keywords
are not supposed to be used as
class name, variable name, function
name etc.use some other non valid
identifier.
2)var_num=num+20;
It is not declared.
Declare this as:
int var_num=num+20;
3)cnum=cnum+25;
The value of a variable declared as
final cannot be changed anywhere
in the program except in the
initialisation part.
4) System.out.println("num is";num);
It should be:-
System.out.println("num is "+num);
Hope this helps you....
Similar questions