0% found this document useful (0 votes)
2K views4 pages

1. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j/m*k; System.out.println(result); Mark for Review (1) Points 0 (*) 4.375 0.175 280 Incorrect. Refer to Section 4 Lesson 3. 2. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j-k%3*m; System.out.println(result); Mark for Review (1) Points 0 16 2 -9 (*) Correct 3. Which of the following is not correct Java code? Mark for Review (1) Points double x=Math.sqrt(16); double x=Math.pow(3,4)*5.0; double x=Math.PI*5.0; double x=Math.pow; (*) Correct 4. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review (1) Points

1. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j/m*k; System.out.println(result); Mark for Review (1) Points 0 (*) 4.375 0.175 280 Incorrect. Refer to Section 4 Lesson 3. 2. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j-k%3*m; System.out.println(result); Mark for Review (1) Points 0 16 2 -9 (*) Correct 3. Which of the following is not correct Java code? Mark for Review (1) Points double x=Math.sqrt(16); double x=Math.pow(3,4)*5.0; double x=Math.PI*5.0; double x=Math.pow; (*) Correct 4. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review (1) Points double a=15^8; double a=Math.pow(5,8); (*) int a=Math.pow(8,5); int a=Math.pow(5,8); double a=pow(8,5); Correct 5. Write a declaration statement that will hold a number like 2.541. Mark for Review (1) Points char number; int number; float number; (*) boolean number; Correct 6. Which of the following is the name of a Java primitive data type? Mark for Review (1) Points String int (*) Rectangle Object Correct 7. Which of the following is not a legal name for a variable? Mark for Review (1) Points R2d2 dgo2sleep 4geeks (*) to_be_or_not_to_be Correct 8. Which of the following examples of Java code is not correct? Mark for Review (1) Points int x=6; double d=4.5; boolean b=1; (*) char c='r'; Correct 9. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review (1) Points double number=3*10^4; double number=3(e4); double number=3e4; (*) double number=3*10e4; Correct 10. Which line of code does not assign 3.5 to the variable x? Mark for Review (1) Points double x=3.5 x=3.5; 3.5=x; (*) x=7.0/2.0; Correct 11. Consider the following: You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable. This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name. True or false? Mark for Review (1) Points True False (*) Correct 12. What will the method methodA print to the screen? Mark for Review (1) Points 18 (*) 15 6 3 Correct 13. Which line of Java code properly calculates the volume of a cone using where r and h are Java primitive integers? Mark for Review (1) Points double V=1/3*3.14*r*r*h; double V=(double)1/3*Math.PI*Math.pow(r,2)*h;

Uploaded by

Si Kecil Madun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views4 pages

1. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j/m*k; System.out.println(result); Mark for Review (1) Points 0 (*) 4.375 0.175 280 Incorrect. Refer to Section 4 Lesson 3. 2. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j-k%3*m; System.out.println(result); Mark for Review (1) Points 0 16 2 -9 (*) Correct 3. Which of the following is not correct Java code? Mark for Review (1) Points double x=Math.sqrt(16); double x=Math.pow(3,4)*5.0; double x=Math.PI*5.0; double x=Math.pow; (*) Correct 4. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review (1) Points

1. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j/m*k; System.out.println(result); Mark for Review (1) Points 0 (*) 4.375 0.175 280 Incorrect. Refer to Section 4 Lesson 3. 2. What is the output of the following lines of code? int j=7,k=5,m=8,result; result=j-k%3*m; System.out.println(result); Mark for Review (1) Points 0 16 2 -9 (*) Correct 3. Which of the following is not correct Java code? Mark for Review (1) Points double x=Math.sqrt(16); double x=Math.pow(3,4)*5.0; double x=Math.PI*5.0; double x=Math.pow; (*) Correct 4. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review (1) Points double a=15^8; double a=Math.pow(5,8); (*) int a=Math.pow(8,5); int a=Math.pow(5,8); double a=pow(8,5); Correct 5. Write a declaration statement that will hold a number like 2.541. Mark for Review (1) Points char number; int number; float number; (*) boolean number; Correct 6. Which of the following is the name of a Java primitive data type? Mark for Review (1) Points String int (*) Rectangle Object Correct 7. Which of the following is not a legal name for a variable? Mark for Review (1) Points R2d2 dgo2sleep 4geeks (*) to_be_or_not_to_be Correct 8. Which of the following examples of Java code is not correct? Mark for Review (1) Points int x=6; double d=4.5; boolean b=1; (*) char c='r'; Correct 9. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review (1) Points double number=3*10^4; double number=3(e4); double number=3e4; (*) double number=3*10e4; Correct 10. Which line of code does not assign 3.5 to the variable x? Mark for Review (1) Points double x=3.5 x=3.5; 3.5=x; (*) x=7.0/2.0; Correct 11. Consider the following: You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable. This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name. True or false? Mark for Review (1) Points True False (*) Correct 12. What will the method methodA print to the screen? Mark for Review (1) Points 18 (*) 15 6 3 Correct 13. Which line of Java code properly calculates the volume of a cone using where r and h are Java primitive integers? Mark for Review (1) Points double V=1/3*3.14*r*r*h; double V=(double)1/3*Math.PI*Math.pow(r,2)*h;

Uploaded by

Si Kecil Madun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1What is the

. output of the
following lines
of code?

Mark for Review


(1) Points

int
j=7,k=5,m=8,
result;
result=j/m*k;
System.out.pri
ntln(result);
0 (*)
4.375
0.175
280
Incorrect. Refer to Section 4 Lesson 3.
2. What is the output of the following lines of code?
int j=7,k=5,m=8,result;
result=j-k%3*m;
System.out.println(result);

Mark
for Review
(1) Points

0
16
2
-9 (*)
Correct
3. Which of the following is not correct Java code?

Mark
for Review
(1) Points

double x=Math.sqrt(16);
double x=Math.pow(3,4)*5.0;
double x=Math.PI*5.0;
double x=Math.pow; (*)
Correct
4. Which line of Java code assigns the value of 5 raised to the power of
8 to a?

Mark
for Review
(1) Points

double a=15^8;
double a=Math.pow(5,8); (*)

int a=Math.pow(8,5);
int a=Math.pow(5,8);
double a=pow(8,5);
Correct
5. Write a declaration statement that will hold a number like 2.541.

Mark
for Review
(1) Points

char number;
int number;
float number; (*)
boolean number;
Correct
6. Which of the following is the name of a Java primitive data type?

Mark
for Review
(1) Points

String
int (*)
Rectangle
Object
Correct
7. Which of the following is not a legal name for a variable?

Mark
for Review
(1) Points

R2d2
dgo2sleep
4geeks (*)
to_be_or_not_to_be
Correct
8. Which of the following examples of Java code is not correct?

Mark
for Review
(1) Points

int x=6;
double d=4.5;
boolean b=1; (*)
char c='r';
Correct
9. Which of the following statements correctly assigns "3 times 10 to
the 4th power" to the variable number?

Mark
for Review
(1) Points

double number=3*10^4;
double number=3(e4);
double number=3e4; (*)
double number=3*10e4;
Correct
10. Which line of code does not assign 3.5 to the variable x?

Mark
for Review
(1) Points

double x=3.5
x=3.5;
3.5=x; (*)
x=7.0/2.0;
Correct
11. Consider the following:
You are writing a class and are using a global variable. Inside a
method you declare a local variable with the same name as the
global variable.

Mark
for Review
(1) Points

This programming style is poor because inside the method the global
variable will have precedence over the local variable with the same
name.
True or false?
True
False (*)
Correct
12. What will the method methodA print to the screen?

Mark

for Review
(1) Points

18 (*)
15
6
3
Correct
13. Which line of Java code properly calculates the volume of a cone
using
where r and h are Java primitive integers?

Mark
for Review
(1) Points

double V=1/3*3.14*r*r*h;
double V=(double)1/3*Math.PI*Math.pow(r,2)*h; (*)
double V=1/3*Math.PI*Math.pow(r,2)*h;
double V=(double)1/3*Math.PI*Math.pow(2,r)*h;
double V=1/3*3.14*r(2)*h;
Correct
14. Given the following declaration: int z=5,m=6;
Which line of Java code properly casts one type into another without
data loss?

double x=(double)z/m; (*)


double x=z/m;
double x=(double)(z/m);
double x= double z/m;
Correct

Mark
for Review
(1) Points

You might also like