Asked by trish
1. Which of the following expression evaluates to a value of 15?
1+2x3+4
(1+2)x(3+4)
1+2x(3+4)
(1+2)x3+4**
2. If x is an int which of the following statements adds 5 to the current value of x and store the new value back in x?
x=5;
x+5; **
x =+ 5;
x += 5;
3. If x is an int which of the following statements increments x by 1?
x = 1;
x+;
x++;
x + 1 = x; **
4. If d is a double variable with a value of 7.5 which of the following statements results in a value of 7 being assigned to x?
int x = (int)d;
int x = d;
int x = int(d); **
double x = d;
5. If the Unicode value for the letter A is 0041. Which of the following statements correctly assigns the value 'A' to char variable n?
char n = 41;
char n = '\u0041 ' ; **
char n = '0041';
char n = A;
Is this all correct? If not can you tell me how I am wrong? Thank you
1+2x3+4
(1+2)x(3+4)
1+2x(3+4)
(1+2)x3+4**
2. If x is an int which of the following statements adds 5 to the current value of x and store the new value back in x?
x=5;
x+5; **
x =+ 5;
x += 5;
3. If x is an int which of the following statements increments x by 1?
x = 1;
x+;
x++;
x + 1 = x; **
4. If d is a double variable with a value of 7.5 which of the following statements results in a value of 7 being assigned to x?
int x = (int)d;
int x = d;
int x = int(d); **
double x = d;
5. If the Unicode value for the letter A is 0041. Which of the following statements correctly assigns the value 'A' to char variable n?
char n = 41;
char n = '\u0041 ' ; **
char n = '0041';
char n = A;
Is this all correct? If not can you tell me how I am wrong? Thank you
Answers
Answered by
Steve
If you're using java, ya gotta stop using "x" for multiplication. Use "*".
#1. Nope
(1+2)*3+4 = 3*3+4 = 9+4 = 13
#2 Nope
x+5 is just an expression which yields the sum of x and 5. It does not update the value of x.
#3 Nope
x+1 = x is invalid syntax. Try it in your java compiler.
#4 Nope
int(d) is invalid. You want to change the type of d, not call a function named "int". Try it out and you will get an error message.
#5 ok
#1. Nope
(1+2)*3+4 = 3*3+4 = 9+4 = 13
#2 Nope
x+5 is just an expression which yields the sum of x and 5. It does not update the value of x.
#3 Nope
x+1 = x is invalid syntax. Try it in your java compiler.
#4 Nope
int(d) is invalid. You want to change the type of d, not call a function named "int". Try it out and you will get an error message.
#5 ok
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.