Shikha is working on a java program in which she has given variables with names"sum,sub,char,div".While executing the program,it shows error.What is her mistake?
Answers
Explanation:
Java has certain keywords or reserved words which convey a special meaning to language compiler.
for example:-
char ,int,new,and ..
while declaring a variable keywords can't used as variable name.however,java is case sensitive language (it can differentiate between lower and upper case).so,keywords can be used as variable name if they aren't written in lower case.
for example:-
int Boolean is correct declaration
[B letter is in capital so,compiler doesn't recognize it]
but
int boolean is incorrect declaration
now back to your question
now back to your questionshikha had made a mistake in declaring the variable name.she had used char as variable name which is a keyword.
if she had written it like Char or CHAR or chAr etc. it wouldn't had been an error.