Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

4Q Exam Generosity Hope Program2025

Total questions: 85

Worksheet time: 1hrs 7mins

Name
Class
Date
1.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
2.

A variable that holds words

a)

String

b)

boolean

c)

int

d)

float

e)

A dictionary

3.

A variable that holds true or false

a)

String

b)

boolean

c)

int

d)

float

e)

Alex Trebek

4.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

5.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

6.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

7.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

8.

What data type would you use for storing the average test score in a class?

a)

double

b)

String

c)

int

d)

char

9.

What data type would you use to store names of students?

a)

String

b)

char

c)

boolean

d)

None of these

e)

blonde

10.

How would you declare a variable storing the tax rate?

a)

int taxRate = 5.1;

b)

taxRate = "5.1";

c)

double taxRate = 5.1;

d)

double taxRate = "5.1";

e)

I do hereby declare thee Sir Tax Rate

11.

How would you declare a variable storing a person's name?

a)

string name = "Elroy";

b)

name String = "Elroy";

c)

String name = Elroy;

d)

String name = "Elroy";

e)

Me llamo Elroy

12.

How would you declare a variable that tells you that someone passed a class?

a)

boolean passed = 'true';

b)

boolean passed = true;

c)

passed = true;

d)

String passed = "true";

e)

Trick question - no one passes this class

13.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

14.

What prints out "I love Java" successfully?

a)

System.out.println(I love Java);

b)

Systemoutprintln("I love Java);

c)

System.out.println("I love" + " Java");

d)

System.out.println("I love Java")

e)

What is love? Baby dont hurt me. Dont hurt me. No more.

15.

Which of the following is NOT a primitive data type?

a)

int

b)

boolean

c)

double

d)

String

16.

What data type should we use to hold a student's average in a class?

a)

int

b)

boolean

c)

double

d)

String

17.

What data type should we use to hold how many student's are in a class?

a)

int

b)

boolean

c)

double

d)

String

18.

What data type should we use to hold the name of your favorite color?

a)

int

b)

boolean

c)

double

d)

String

19.

What data type should we use to hold if you have a pet -to agree or disagree?

a)

int

b)

boolean

c)

double

d)

String

20.

True or false:

This is a correct initialization of a variable.


int numBooks = 6;

a)

true

b)

false

21.

True or false:

This is a correct initialization of a variable.


int myTemperature = 98.2;

a)

true

b)

false

22.

True or false:

This is a correct initialization of a variable.


String name = Bob;

a)

true

b)

false

23.

True or false:

This is a correct initialization of a variable.


String favoriteDay = "Saturday";

a)

true

b)

false

24.

True or false:

This is a correct initialization of a variable.


boolean happy = true;

a)

true

b)

false

25.

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();

a)

import Java.util.Scanner;

b)

import java.util.scanner;

c)

import java.util.Scanner;

d)

Import java.util.scanner;

26.

Which of the following is a LEGAL identifier?

a)

Num1+Num2

b)

1stQuarterExam

c)

$finalScore

d)

String

27.

Which of the following statement is CORRECT?

a)

System.out.println(“Be Happy);

b)

System.out.println(“Be Happy”)

c)

System.out.println(“Be Happy”);

d)

System.out.println(Be Happy);

28.

Who is the father of Java?

a)

James A. Gosling

b)

Bill Gates

c)

Steve Jobs

d)

Dennis Ritchie

29.

Which of the following statement is NOT true?

a)

Every Java program starts from a main method

b)

In Java, OK and ok are not the same

c)

// indicates a comment line

d)

Char is a reserved word

30.

Which of the following is NOT a Java data type?

a)

String

b)

double

c)

boolean

d)

static

31.

Which of the following is the equivalent compound statement, x = x + 5;?

a)

x=+5;

b)

x++5;

c)

x+=5;

d)

xx=5;

32.

Which of the following is NOT a correct variable declaration?

a)

int x, y = 10;

b)

double p = 10%;

c)

String message;

d)

char choice = ‘Y’;

33.

What is the output of the statement, System.out.print(15 >= 15);

a)

15

b)

true

c)

false

d)

compile error

34.

What is the output of the statement, System.out.print((int)(5.1+5.3*2)) ?

a)

15

b)

20.8

c)

15. 7

d)

20

35.

Which of the following is NOT a relational operator?

a)

<

b)

<>

c)

>=

d)

!=

36.

Identify the output of the following code:

int grade = 80;

if(grade>80)

System.out.print(“great”);

System.out.print(“job”);

a)

great

b)

job

c)

greatjob

d)

jobgreat

37.

Identify the output of the following code:

String section = “Kindness”;

int grade = 11;

System.out.printf(“Grade %d - %s”, grade, section);

a)

11 Kindness

b)

Grade 11 Kindness

c)

Grade 11 - Kindness

d)

Grade Kindness 11

38.

Identify the output of the following code:

int number = 15;

if(number %2 == 0)

System.out.print(“Even”);

else

System.out.print(“Odd”);

a)

Even

b)

Odd

c)

EvenOdd

d)

OddEven

39.

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);

a)

22.75

b)

43.5

c)

102.0

d)

45.5

40.

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”);

a)

Awesome

b)

StillAwesome

c)

AwesomeStillAwesome

d)

No output

41.

Which of the following is NOT a logical operator?

a)

&&

b)

!

c)

||

d)

!=

42.

Which is the alternative to switch in Java language?

a)

break, continue

b)

for,while

c)

if-else

d)

goto, exit

43.

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");

}

a)

APPLE

b)

ORANGE

c)

APPLEORANGE

d)

Compile error

44.

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");

}

a)

TEN

b)

TWENTY

c)

THIRTY

d)

TENTWENTY

45.

Which of the following import statement is INCORRECT?

a)

import java.util.Scanner;

b)

import javax.swing.JOptionPane;

c)

import java.awt.*;

d)

import java.sql;

46.

What is the output of the statement, System.out.println(“\\\\wow////”); ?

a)

\\wow////

b)

\\\\wow////

c)

\\wow//

d)

\\\\wow//

47.

Identify the output of the following code:

for(int i = 0; i < 5; i++)

System.out.print("&");

a)

&

b)

&&&&

c)

&&&&&

d)

&&&&&&

48.

Identify the output of the following code:

int count = 1;

int x = 5;

while (count < 5){

x = x - 1;

count++;

}

System.out.println(x);

a)

5

b)

4

c)

1

d)

0

49.

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;

}

a)

5 3 2 1

b)

6 4 2 1

c)

5 4 3 2

d)

4 3 2 1

50.

Identify the output of the following code:

int x = 2, y = 6;

do {

x = x + 2;

} while (x < y);

System.out.print(x + " " + y);

a)

2 6

b)

2 4

c)

6 6

d)

6 2

51.

How many times does the following method print a *?

a)

9

b)

6

c)

7

d)

10

52.

What does the following code segment print?

a)

5 4 3 2 1

b)

-5 -4 -3 -2 -1

c)

-4 -3 -2 -1 0

53.
Which of the following loops prints "Welcome to Java" 10 times?
a)
A:
for (int count = 1; count <= 10; count++) {
 System.out.println("Welcome to Java");
b)
for (int count = 2; count < 10; count++) {
 System.out.println("Welcome to Java");
}
c)
for (int count = 1; count < 10; count++) {
 System.out.println("Welcome to Java");
}
d)
for (int count = 0; count <= 10; count++) {
 System.out.println("Welcome to Java");
}
54.
How many times will this loop run?
for(int i = 0; i < 9; i = i + 3)
        out. print("foo");
a)
1
b)
2
c)
3
d)
4
55.
a)

200 66 22 7 2

b)

66 22 7 2

c)

200 66 22 2

d)

200 66 22

e)

7

56.

What is the output of the following Java code?

int num = 5;

while (num > 5) {

num = num + 2;

}

System.out.println(num);

(a)  

57.

A while loop has the following format:

a)

while (condition)

{

...

}

b)

while

{

...

}

c)

continue while (condition)

{

...

}

d)

while [condition]

[

...;

]

58.

What is the output of the following code snippet?

int time = 20;

String result = (time < 18) ? "Good day." : "Good evening.";

System.out.println(result);

a)

20

b)

18

c)

Good day

d)

Good evening

59.

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);

a)

5

b)

10

c)

x

d)

y

60.

General format of if-else statement is :

a)

if(condition)

Statement1;

b)

if

Statement1;

else

Statement2;

c)

if(condition)

Statement1;

else

Statement2;

61.

General format of "simple if" statement is

a)

if(condition)

Statement1;

else

Statement2;

b)

if(condition)

Statement;

c)

if

Statement1;

62.

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");

a)

Red

b)

Blue

c)

Purple

d)

Gold

63.

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");

a)

Red

b)

Blue

c)

Purple

d)

Gold

64.

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");

a)

Red

b)

Blue

c)

Purple

d)

Gold

65.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

66.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

67.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

68.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

69.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

70.

What data type would you use for storing the average test score in a class?

a)

double

b)

String

c)

int

d)

char

71.

How would you declare a variable storing a person's name?

a)

string name = "Jeff";

b)

name String = "Jeff";

c)

String name = Jeff;

d)

String name = "Jeff";

72.

How would you declare a variable storing the tax rate?

a)

int taxRate = 5.1;

b)

taxRate = "5.1";

c)

double taxRate = 5.1;

d)

double taxRate = "5.1";

73.

How would you declare a variable that tells you that someone passed a class?

a)

boolean passed = 'true';

b)

boolean passed = true;

c)

passed = true;

d)

String passed = "true";

74.

Which expression evaluates to false?

a)

15 % 3 < 2

b)

3 * 3 % 2 <= 0

c)

false == false

d)

false == false == false == false

75.

What is the exact output of the following Java statement?


System.out.println(15 / 2);

(a)  

76.

What is the exact output of the following Java statement?


System.out.println(3 + 5.3);

(a)  

77.

What is the exact output of the following Java statement?


System.out.println(22 / 2.0);

(a)  

78.

What is the exact output of the following Java statement?


System.out.println(18 % 7);

(a)  

79.

What is the exact output of the following Java statement?


System.out.println(4 * 3.0);

(a)  

80.

What is the exact output of the following Java statement?


System.out.println(22 / 2.0);

(a)  

81.

What is the exact output of the following Java statement?


System.out.println((int) 4.6);

(a)  

82.

What is the exact output of the following Java statement?


System.out.println((double) 16);

(a)  

83.

What is the exact output of the following Java statement?


System.out.println((int) 43.59);

(a)  

84.

This statement y = y * 5 + z is equivalent to __________.

a)

y *= 5 + z

b)

y =* 5 + z

c)

y = 5 + z;

d)

y * 5 + z = y

85.

This statement z = z % 3 is equivalent to __________.

a)

z %= z + 3

b)

z %= 3

c)

z =% 3

d)

z % 3 = z