You are on page 1of 6

Section 3 Quiz 1 - L1-L2

(Answer all questions in this section)


1. What is the output? public static void main(String args[]) {
int x = 100;
int y = x;
y++;
System.out.println("Value of x is " + x);
System.out.println("Value of y is " + y);
}
Mark for Review

(1) Points
Value of x is 0
Value of y is 1

m
Value of x is 100

er as
Value of y is 1

co
eH w
Value of x is 100
Value of y is 1

o.
Value of x is 100
rs e
ou urc
Value of y is 101 (*)
Correct
o

2. Assuming x is an int, which of the following are ways to increment the


aC s

value of x by 1?
vi y re

Mark for Review

(1) Points
ed d

x = x +1;(*)
ar stu

x = +1;

x+;
is

x++;(*)

x += 1;(*)
Th

Correct

3. How many bits are in a byte?


sh

Mark for Review

(1) Points
2
4

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
6
7
8 (*)
Correct

4. Which keyword makes a variable’s value unchangeable?


Mark for Review

(1) Points
const
final (*)
static
break

m
er as
Correct

co
eH w
5. Which of the following data types is the largest?

o.
Mark for Review
rs e
ou urc
(1) Points
byte
o

short
aC s

int
vi y re

long (*)
Correct
6. What is the output?
ed d
ar stu

public class Person {


public static void main(String args[]) {
int age = 20;
is

System.out.println("Value of age: " +age);


age = 5 + 3;
Th

System.out.println("Value of age: " +age);


age = age + 1;
age++;
sh

System.out.println("Value of age: " +age);


}
}
Mark for Review

(1) Points

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
Value of age: 20
Value of age: 8
Value of age: 10 (*)
Value of age: 20
Value of age: 28
Value of age: 38
Value of age: 20
Value of age: 208
Value of age: 20810
Value of age: 20
Value of age: 8
Value of age: 9
Correct

m
er as
7. What value is assigned to x?

co
eH w
int x = 25 - 5 * 4 / 2 - 10 + 4;

o.
Mark for Review

rs e
ou urc
(1) Points
8
9 (*)
o

34
aC s
vi y re

7
Correct
ed d

8. Which data type is most commonly used to represent numeric data?


ar stu

Mark for Review

(1) Points
is

int (*)
float
Th

String
short
sh

Correct

9. Java is a strongly typed language; therefore you must declare a data type
for all variables.
Mark for Review

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
(1) Points
True (*)
False
Correct

10. Which two statements will not compile?


Mark for Review

(1) Points
double salary = 20000.34;

int abc = 10;

int age=20;

m
double double=10;(*)

er as
int break=10;(*)

co
eH w
Correct

o.
11. Identify the names of two variables used in the given code.
rs e
ou urc
public class Variables {
public static void main(String args[]) {
String strVal = "Hello";
o

int intVal = 0;
aC s

System.out.println("Integer: " +intVal)


vi y re

}
}
Mark for Review
ed d

(1) Points
ar stu

strVal(*)

String
is

int
Th

Hello

intVal(*)
Correct
sh

12. What is the output?

public class Hello {


public static void main(String args[]) {
String str = ”Hello”;

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
str = ”World”;
System.out.println(str);
}
}
Mark for Review

(1) Points
Hello
Hello
World
World (*)
Hello World
Correct

m
er as
13. Which of the following two statements are true about variables?

co
Mark for Review

eH w
o.
(1) Points
rs e
They make code more flexible.(*)
ou urc
Variables will be ignored by compiler.

The value assigned to a variable may never change.


o

The allow code to be edited more efficiently.(*)


aC s

Correct
vi y re

14. Which two are valid?


Mark for Review
ed d
ar stu

(1) Points
double doubleVar1, double doubleVar2 = 3.1;

double doubleVar1; doubleVar2 = 3.1.


is

double doubleVar1, doubleVar2 = 3.1;(*)


Th

double doubleVar1 = 3.1; double doubleVar2 = 3.1;(*)


Incorrect. Refer to Section 3 Lesson 1.
sh

15. Which two data types are appropriate for their variable?
Mark for Review

(1) Points
String firstName = “Alex”;(*)

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
double checkingAmount = 1500;(*)

int averageDollarAmount = 19.95;

boolean age = 20;


Correct

m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000815348412 from CourseHero.com on 07-28-2021 21:41:20 GMT -05:00

https://www.coursehero.com/file/68385896/JFo-Section-3-Quiz-1-L1-L2docx/
Powered by TCPDF (www.tcpdf.org)

You might also like