JAVA Programming :: Basic Concepts - Discussion
Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion
36 / 64
What is the output for the below code?
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
A7 9 0
B7 0 0
CCompile error - $7 is not valid identifier.
DCompile error - do is not valid identifier.
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
do is an illegal name for an identifier, because as per the naming convention says, you cannot use a reserved keyword as an identifier name.
More info about naming conventions for identifiers are as follows-
1. All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_).
2. After the first character, identifiers can have any combination of characters.
3. A keyword cannot be used as an identifier.
4. Most importantly, identifiers are case sensitive.
Read Full Answer
Report Error
Please Login First Click Here