
Java Basics #2
Authored by Jennifer Hoagland
Computers
10th - 12th Grade
Used 65+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Soal Ujian Komputer
Quiz
•
10th - 12th Grade
10 questions
BÀI KIỂM TRA GIỮA KÌ 2 - LỚP 3
Quiz
•
1st - 10th Grade
10 questions
acTIC - Competència 6.1 – Conceptes bàsics full de càlcul
Quiz
•
10th Grade
10 questions
Scratch
Quiz
•
KG - Professional Dev...
10 questions
Network Security
Quiz
•
9th - 11th Grade
10 questions
What is a program slides(6:16)
Quiz
•
8th - 12th Grade
10 questions
BÀI KIỂM TRA 15P HK2 TIN HỌC 11
Quiz
•
11th Grade
11 questions
Youtube
Quiz
•
4th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade