Java Basics #2

Quiz
•
Computers
•
10th - 12th Grade
•
Hard
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
Similar Resources on Wayground
10 questions
AppsLab_Q2

Quiz
•
10th Grade - Professi...
10 questions
Python_10 câu

Quiz
•
10th Grade
8 questions
Lesson 5 Practice Problems

Quiz
•
9th Grade - University
10 questions
Programming with C++

Quiz
•
9th - 12th Grade
10 questions
Sains Komputer : 1.6.1

Quiz
•
12th Grade
10 questions
LATIHAN 4

Quiz
•
10th Grade
9 questions
AP CS A Quiz 4 Practice

Quiz
•
9th - 12th Grade
10 questions
Программирование C#

Quiz
•
1st - 10th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade