Variables
Write a line of code to (1) declare a variable cost and (2) assign it a value of 12.51. |
double cost = 12.51; |
|
Write a line of code to (1) declare a String variable course and (2) assign it the value "Udacity". |
String course = "Udacity"; |
|
Given the following line of code:
int count = 1;write the line of code to assign the value 100 to count. |
count = 100; |
|
What is the value of mystery after the following sequence of statements?
int mystery = 10; mystery = mystery * 2; mystery = 7 - mystery; |
-13 |
Which of the following are valid variable names in Java?
- Valid|Invalid
age - Valid|Invalid
classclassis a reserved word. - Valid|Invalid
intintis a reserved word. - Valid|Invalid
7ofSpacesA variable name cannot start with a digit. - Valid|Invalid
K@udacityA variable name cannot contain symbols such as@. - Valid|Invalid
bank accountA variable name cannot contain spaces. - Valid|Invalid
costPerUnitLowercase and uppercase letters are ok.
Given the importance of variable names, which of the following choices is the best name for a variable to hold the area of a square?
asxareaOfSquarearea