0

Mark the following declarations as correct/incorrect

string ‘student’; float Double; int double; double username char ‘a’;

2nd Dec 2022, 4:58 AM
Jaimz
Jaimz - avatar
5 Answers
+ 3
confused variable name assignment... string ‘student’; //incorrect. String not string. cannot use '' in variable name. String student; //suggested correction float Double; //valid. but confusing and not recommended because double is a reserved keyword and capitalized variables are generally used for class names. float average; //suggest a more practical name. int double; //incorrect. double is a reserved keyword and must not be used as variable name. double username //incorrect. it is not properly terminated with a semicolon ";" double username; //suggested correction //char ‘a’; //incorrect. cannot use '' in variable name. char a; //suggested correction
2nd Dec 2022, 5:29 AM
Bob_Li
Bob_Li - avatar
+ 3
but you still try to be diligent to think and show your opinion
2nd Dec 2022, 8:15 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Try to run it and the compiler will tell you if they are not valid. You can just start a new Java code bit on Sololearn for that. As far as I can tell only 1 line is valid (although it is not encouraged).
2nd Dec 2022, 9:22 AM
Lochard
Lochard - avatar
0
Hi! it is interesting to see what your opinion on this matter is. share?
2nd Dec 2022, 5:07 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
It's an assignment and I'm not completely sure about my answers
2nd Dec 2022, 5:13 AM
Jaimz
Jaimz - avatar