πŸ“Š JAVA
Q. 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._$);
}
}
  • (A) 7 9 0
  • (B) 7 0 0
  • (C) Compile error - $7 is not valid identifier.
  • (D) Compile error - $7 is not valid identifier. D. Compile error - do is not valid identifier.
πŸ’¬ Discuss
βœ… Correct Answer: (D) Compile error - $7 is not valid identifier. D. Compile error - do is not valid identifier.

Explanation: $7 is valid identifier. Identifiers must start with a letter, a currency character ($), or underscore ( _ ). Identifiers cannot start with a number. You can't use a Java keyword as an identifier. do is a Java keyword.

Explanation by: Bhagwan Das
$7 is valid identifier. Identifiers must start with a letter, a currency character ($), or underscore ( _ ). Identifiers cannot start with a number. You can't use a Java keyword as an identifier. do is a Java keyword.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
107
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Bhagwan Das
Publisher
πŸ“ˆ
85%
Success Rate