Worksheets4Q Exam Generosity Hope Program2025
Total questions: 85
Worksheet time: 1hrs 7mins
A variable that holds words
String
boolean
int
float
A dictionary
A variable that holds true or false
String
boolean
int
float
Alex Trebek
Name the data type: 1.0
double
int
char
boolean
Name the data type: "true"
boolean
char
String
double
Name the data type: false
String
boolean
int
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What data type would you use for storing the average test score in a class?
double
String
int
char
What data type would you use to store names of students?
String
char
boolean
None of these
blonde
How would you declare a variable storing the tax rate?
int taxRate = 5.1;
taxRate = "5.1";
double taxRate = 5.1;
double taxRate = "5.1";
I do hereby declare thee Sir Tax Rate
How would you declare a variable storing a person's name?
string name = "Elroy";
name String = "Elroy";
String name = Elroy;
String name = "Elroy";
Me llamo Elroy
How would you declare a variable that tells you that someone passed a class?
boolean passed = 'true';
boolean passed = true;
passed = true;
String passed = "true";
Trick question - no one passes this class
Which declaration will throw an error?
double num = 8;
int averageGrade = 89.7;
boolean done = false;
String done = "true";
What prints out "I love Java" successfully?
System.out.println(I love Java);
Systemoutprintln("I love Java);
System.out.println("I love" + " Java");
System.out.println("I love Java")
What is love? Baby dont hurt me. Dont hurt me. No more.
Which of the following is NOT a primitive data type?
int
boolean
double
String
What data type should we use to hold a student's average in a class?
int
boolean
double
String
What data type should we use to hold how many student's are in a class?
int
boolean
double
String
What data type should we use to hold the name of your favorite color?
int
boolean
double
String
What data type should we use to hold if you have a pet -to agree or disagree?
int
boolean
double
String
True or false:
This is a correct initialization of a variable.
int numBooks = 6;
true
false
True or false:
This is a correct initialization of a variable.
int myTemperature = 98.2;
true
false
True or false:
This is a correct initialization of a variable.
String name = Bob;
true
false
True or false:
This is a correct initialization of a variable.
String favoriteDay = "Saturday";
true
false
True or false:
This is a correct initialization of a variable.
boolean happy = true;
true
false
What is the Package used for the program below:
Scanner mukuha = new Scanner (System.in);
System.out.print("Isulat ang pangalan sa uyab: ");
String uyab = mukuha.nextLine();
import Java.util.Scanner;
import java.util.scanner;
import java.util.Scanner;
Import java.util.scanner;
Which of the following is a LEGAL identifier?
Num1+Num2
1stQuarterExam
$finalScore
String
Which of the following statement is CORRECT?
System.out.println(“Be Happy);
System.out.println(“Be Happy”)
System.out.println(“Be Happy”);
System.out.println(Be Happy);
Who is the father of Java?
James A. Gosling
Bill Gates
Steve Jobs
Dennis Ritchie
Which of the following statement is NOT true?
Every Java program starts from a main method
In Java, OK and ok are not the same
// indicates a comment line
Char is a reserved word
Which of the following is NOT a Java data type?
String
double
boolean
static
Which of the following is the equivalent compound statement, x = x + 5;?
x=+5;
x++5;
x+=5;
xx=5;
Which of the following is NOT a correct variable declaration?
int x, y = 10;
double p = 10%;
String message;
char choice = ‘Y’;
What is the output of the statement, System.out.print(15 >= 15);
15
true
false
compile error
What is the output of the statement, System.out.print((int)(5.1+5.3*2)) ?
15
20.8
15. 7
20
Which of the following is NOT a relational operator?
<
<>
>=
!=
Identify the output of the following code:
int grade = 80;
if(grade>80)
System.out.print(“great”);
System.out.print(“job”);
great
job
greatjob
jobgreat
Identify the output of the following code:
String section = “Kindness”;
int grade = 11;
System.out.printf(“Grade %d - %s”, grade, section);
11 Kindness
Grade 11 Kindness
Grade 11 - Kindness
Grade Kindness 11
Identify the output of the following code:
int number = 15;
if(number %2 == 0)
System.out.print(“Even”);
else
System.out.print(“Odd”);
Even
Odd
EvenOdd
OddEven
Identify the output of the following code:
double rate = 45.5;
if(rate > 50.0)
System.out.println(rate * 2);
else if(rate >= 40.0)
System.out.println(rate / 2);
else
System.out.println(rate – 2);
22.75
43.5
102.0
45.5
Identify the output of the following code:
int score = 55;
char gender = ‘F’;
if(score > 10 || gender == ‘M’)
System.out.print(“Awesome”);
if(score > 10 || gender == ‘F’)
System.out.print(“Still Awesome”);
Awesome
StillAwesome
AwesomeStillAwesome
No output
Which of the following is NOT a logical operator?
&&
!
||
!=
Which is the alternative to switch in Java language?
break, continue
for,while
if-else
goto, exit
Identify the output of the following code:
int numFruits = 45;
int choice = 45;
switch(choice) {
case numFruits: System.out.print("APPLE ");
default: System.out.println("ORANGE");
}
APPLE
ORANGE
APPLEORANGE
Compile error
Identify the output of the following code:
int num=20;
switch(num){
case 10: System.out.println("TEN"); break;
case 20: System.out.println("TWENTY"); break;
case 30: System.out.println("THIRTY");
}
TEN
TWENTY
THIRTY
TENTWENTY
Which of the following import statement is INCORRECT?
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.awt.*;
import java.sql;
What is the output of the statement, System.out.println(“\\\\wow////”); ?
\\wow////
\\\\wow////
\\wow//
\\\\wow//
Identify the output of the following code:
for(int i = 0; i < 5; i++)
System.out.print("&");
&
&&&&
&&&&&
&&&&&&
Identify the output of the following code:
int count = 1;
int x = 5;
while (count < 5){
x = x - 1;
count++;
}
System.out.println(x);
5
4
1
0
Identify the output of the following code:
int num = 6;
while(num >= 0){
if(num % 5 == 0){
num++;
continue;
}
System.out.print(num + " ");
num = num - 2;
}
5 3 2 1
6 4 2 1
5 4 3 2
4 3 2 1
Identify the output of the following code:
int x = 2, y = 6;
do {
x = x + 2;
} while (x < y);
System.out.print(x + " " + y);
2 6
2 4
6 6
6 2
How many times does the following method print a *?
9
6
7
10
What does the following code segment print?
5 4 3 2 1
-5 -4 -3 -2 -1
-4 -3 -2 -1 0
for (int count = 1; count <= 10; count++) {
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
}
System.out.println("Welcome to Java");
}
System.out.println("Welcome to Java");
}
for(int i = 0; i < 9; i = i + 3)
out. print("foo");
200 66 22 7 2
66 22 7 2
200 66 22 2
200 66 22
7
What is the output of the following Java code?
int num = 5;
while (num > 5) {
num = num + 2;
}
System.out.println(num);
(a)
A while loop has the following format:
while (condition)
{
...
}
while
{
...
}
continue while (condition)
{
...
}
while [condition]
[
...;
]
What is the output of the following code snippet?
int time = 20;
String result = (time < 18) ? "Good day." : "Good evening.";
System.out.println(result);
20
18
Good day
Good evening
What is the output of the following code snippet?
int x = 5;
int y = 10;
int max = (x > y) ? x : y;
System.out.println(max);
5
10
x
y
General format of if-else statement is :
if(condition)
Statement1;
if
Statement1;
else
Statement2;
if(condition)
Statement1;
else
Statement2;
General format of "simple if" statement is
if(condition)
Statement1;
else
Statement2;
if(condition)
Statement;
if
Statement1;
What will be the output of the following code:
int x=0;
if (x < 10) System.out.println("Red");
else if (x >= 50)System.out.println("Blue");
else if (x ==71) System.out.println("Purple");
else System.out.println("Gold");
Red
Blue
Purple
Gold
What will be the output of the following code:
int x=71;
if (x < 10) System.out.println("Red");
else if (x >= 50)System.out.println("Blue");
else if (x ==71) System.out.println("Purple");
else System.out.println("Gold");
Red
Blue
Purple
Gold
What will be the output of the following code:
int x=81;
if (x < 10) System.out.println("Red");
else if (x >= 100)System.out.println("Blue");
else if (x ==71) System.out.println("Purple");
else System.out.println("Gold");
Red
Blue
Purple
Gold
Name the data type: "true"
boolean
char
String
double
Name the data type: 1.0
double
int
char
boolean
Name the data type: '3'
int
char
String
None of the above
Name the data type: false
String
boolean
int
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What data type would you use for storing the average test score in a class?
double
String
int
char
How would you declare a variable storing a person's name?
string name = "Jeff";
name String = "Jeff";
String name = Jeff;
String name = "Jeff";
How would you declare a variable storing the tax rate?
int taxRate = 5.1;
taxRate = "5.1";
double taxRate = 5.1;
double taxRate = "5.1";
How would you declare a variable that tells you that someone passed a class?
boolean passed = 'true';
boolean passed = true;
passed = true;
String passed = "true";
Which expression evaluates to false?
15 % 3 < 2
3 * 3 % 2 <= 0
false == false
false == false == false == false
What is the exact output of the following Java statement?
System.out.println(15 / 2);
(a)
What is the exact output of the following Java statement?
System.out.println(3 + 5.3);
(a)
What is the exact output of the following Java statement?
System.out.println(22 / 2.0);
(a)
What is the exact output of the following Java statement?
System.out.println(18 % 7);
(a)
What is the exact output of the following Java statement?
System.out.println(4 * 3.0);
(a)
What is the exact output of the following Java statement?
System.out.println(22 / 2.0);
(a)
What is the exact output of the following Java statement?
System.out.println((int) 4.6);
(a)
What is the exact output of the following Java statement?
System.out.println((double) 16);
(a)
What is the exact output of the following Java statement?
System.out.println((int) 43.59);
(a)
This statement y = y * 5 + z is equivalent to __________.
y *= 5 + z
y =* 5 + z
y = 5 + z;
y * 5 + z = y
This statement z = z % 3 is equivalent to __________.
z %= z + 3
z %= 3
z =% 3
z % 3 = z
