Java Basics #2

Java Basics #2

10th - 12th Grade

7 Qs

quiz-placeholder

Similar activities

Lecture 4.4 Part 2

Lecture 4.4 Part 2

12th Grade

11 Qs

Project-Stem Unit 1 python coding

Project-Stem Unit 1 python coding

9th - 12th Grade

12 Qs

Session 1

Session 1

9th - 12th Grade

10 Qs

Variables in C++

Variables in C++

9th - 12th Grade

10 Qs

Compound Operators in Java

Compound Operators in Java

9th - 12th Grade

12 Qs

JS Practice: ITS Certification

JS Practice: ITS Certification

12th Grade

10 Qs

Loops

Loops

9th - 12th Grade

10 Qs

AP CSA Unit 1 & 2 Review

AP CSA Unit 1 & 2 Review

9th - 12th Grade

10 Qs

Java Basics #2

Java Basics #2

Assessment

Quiz

Computers

10th - 12th Grade

Hard

Created by

Jennifer Hoagland

Used 63+ times

FREE Resource

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Consider the following code segment:

Line 1: int a = 10;

Line 2: double b = 10.7;

Line 3: double c = a + b;

Line 4: int d = a + c;

Line 5: System.out.println(c + " " + d);


What will be output as a result of executing the code segment?

20 20

20.0 30

20.7 31

20.7 30.7

Nothing will be printed because of a compile-time error.

2.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Consider the following code segment:

Line 1: int a = 10;

Line 2: double b = 10.7;

Line 3: int d = a + b;


Line 3 will not compile in the code segment above. With which of the following statements could we replace this line so that is compiles?


I. int d = (int) a + b;

II. int d = (int) (a + b);

III. int d = a + (int) b;

I

II

III

I and III

II and III

3.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Consider the following code segment:


Line 1: int a = 11;

Line 2: int b = 4;

Line 3: double x = 11;

Line 4: double y = 4;

Line 5: System.out.print(a / b);

Line 6: System.out.print(", ");

Line 7: System.out.print(x / y);

Line 8: System.out.print(", ");

Line 9: System.out.print(a / y);


What is printed as a result of executing the code segment?

3, 2.75, 3

3, 2.75, 2.75

2, 3, 2

2, 2,75, 2.75

Nothing will be printed because of a compile-time error.

4.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Consider the following code segment:


int var = 12;

var = var % 7;

var = var - 1;

System.out.println(var);


What is printed as a result of executing the code segment?

0

1

2

4

5

5.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Consider the following code segment:


int count = 5;

double multiplier = 2.5;

int answer = (int)(count * multiplier);

answer = (answer * count) % 10;

System.out.println(answer);


What is printed as a result of executing the code segment?

0

2.5

6

12.5

60

6.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Assume that a, b, and c have been declared and initialized with int values. The expression


!(a > b || b <= c)


is equivalent to which of the following?

a > b && b <= c

a <= b || b > c

a <= b && b > c

a < b || b >= c

a < b && b >= c

7.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Assume that x, y, and z have been declared as follows:


boolean x = true;

boolean y = false;

boolean z = true;


Which of the following expressions evaluates to true?

x && y && z

x && y || z && y

!(x && y) || z

!(x || y) && z

x && y || !z