Friday, 10 July 2009

Java Certification Question 0030

Which of the following statements are true?
1) The % is used to calculate a percentage thus: 10 % 20=50
2) The / operator is used to divide one value by another
3) The # symbol may not be used as the first character of a variable
4) The $ symbol may not be used as the first character of a variable



Answer :
2) The / operator is used to divide one value by another
3) The # symbol may not be used as the first character of a variable
The % is the modulo operator and returns the remainder after a division. Thus 10 % 3=1
The $ symbol may be used as the first character of a variable, but I would suggest that it is generally not a good idea. The # symbol cannot be used anywhere in the name of a variable. Knowing if a variable can start with the # or $ characters may seem like arbitrary and non essential knowlege but questions like this do come up on the exam.

No comments:

Post a Comment