wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

First Quarter Summative Test - September 19, 2024

Total questions: 81

Worksheet time: 1hrs 24mins

Name
Class
Date
1.

Which of the following is a LEGAL identifier?

a)

Num1+Num2

b)

1stQuarterExam

c)

$finalScore

d)

String

2.

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

3.

Who is the father of Java?

a)

James A. Gosling

b)

Bill Gates

c)

Steve Jobs

d)

Dennis Ritchie

4.

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

5.

Which of the following is NOT a Java data type?

a)

String

b)

double

c)

boolean

d)

static

6.

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

a)

x=+5;

b)

x++5;

c)

x+=5;

d)

xx=5;

7.

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

8.

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

a)

15

b)

true

c)

false

d)

compile error

9.

Which of the following statement is INCORRECT?

a)

Integer.parseInt(input);

b)

Double.parseDouble(input);

c)

Float.parseFloat(input);

d)

String.parseString(input);

10.

Which of the following does NOT belong to the group?

a)

JOptionPane.INFORMATION_MESSAGE;

b)

JOptionPane.ERROR_MESSAGE;

c)

JOptionPane.QUESTION_MESSAGE;

d)

JOptionPane.WARN_MESSAGE;

11.

What is the result of the logical expression,

(true || false) && (false || false) ?

a)

true

b)

false

12.

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

13.

Which of the following is NOT a relational operator?

a)

<

b)

<>

c)

>=

d)

!=

14.

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

15.

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

16.

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

17.

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

18.

Which of the following statements produces error?

a)

int c = (a > b) ? 10: 15;

b)

int x = (a % 2==0) ? “even” : “odd”;

c)

String y = (a == “Apple”) ? “fruit”, “vegetable”;

d)

char res = (a != b) ? ‘A’ : ‘B’;

19.

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

20.

Identify the output of the following code:

int num1 = 10, num2 = 15;

int min = (num1 < num2) ? 10 : 15;

System.out.println(min);

a)

10

b)

15

c)

1015

d)

No output

21.

Which of the following is NOT a logical operator?

a)

&&

b)

!

c)

||

d)

!=

22.

Which is the alternative to switch in Java language?

a)

break, continue

b)

for,while

c)

if-else

d)

goto, exit

23.

A switch statement accepts ___ type of data as input.

a)

byte

b)

int

c)

short

d)

all of the choices

24.

A switch fall through occurs in Java only in the absence of ___.

a)

case

b)

break

c)

default

d)

none of these

25.

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

26.

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

27.

Which of the following is NOT a reserved word or keyword?

a)

main

b)

class

c)

string

d)

void

28.

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;

29.

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

a)

\\wow////

b)

\\\\wow////

c)

\\wow//

d)

\\\\wow//

30.

Which of the following is NOT true about a loop?

a)

In Java, while is a reserved word

b)

The statement is called the body of the loop

c)

Java has three looping structures: while, for, do-while

d)

In an infinite loop, the loop condition is initially false, but after the first iteration, it is always true

31.

Identify the output of the following code:

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

System.out.print("&");

a)

&

b)

&&&&

c)

&&&&&

d)

&&&&&&

32.

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

33.

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

34.

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

35.

Which of the following stament is INCORRECT?

a)

char[] gender = {‘M’, ‘F’};

b)

String[] colors = {“red”, “green”, “blue”};

c)

double[] salary = new salary[0];

d)

int[] omega = new int[50];

36.

Identify the output of the following code:

String[] names = {“Kylie”, “Aljur”, “AJ”, “JM”};

System.out.println(names[3]);

a)

Kylie

b)

Aljur

c)

AJ

d)

JM

37.

Identify the output of the following code:

char[][] letters = {{‘A’, ‘E’, ‘I’, ‘O’, ‘U’}, {‘X’, ‘Y’,’Z’}};

System.out.print(letters[1][2]);

a)

E

b)

Y

c)

I

d)

Z

38.

Identify the output of the following code:

int[] nums = {1, 5, 7, 9, 11, 13, 15, 17};

String str = {"Kindness", "Generosity"};

System.out.println(nums.length);

a)

2

b)

0

c)

8

d)

Compile error

39.

What is the array name of the following statement?


double[] scores = new double[40];

a)

double

b)

new

c)

scores

d)

40

40.

What will be the output to the console of the code below?


int my3DArray[][][]= {{{1,2,3,},{4,5,6}},{{7,8,9},{10,11,12}}};


System.out.println(my3DArray.length);

a)

2

b)

1

c)

3

d)

4

41.

What will be the output to the console of the code below?


int my3DArray[][][]= {{{1,2,3,},{4,5,6}},{{7,8,9},{10,11,12}}};


System.out.println(my3DArray[0][1][0]);

a)

4

b)

1

c)

10

d)

2

42.

What will be the output to the console of the code below?


int my2DArray[][]= {{1,2,3,},{4,5,6},{7,8,9}};


System.out.println(my2DArray[2][2]);

a)

9

b)

8

c)

4

d)

3

43.

Which of the following statements correctly declares a two-dimensional integer array?

a)

int Matrix[ ] = new int[5,4];

b)

int Matrix[ ]; Matrix = new int[5,4];

c)

int Matrix[ ][ ] = new int[5][4];

d)

int Matrix[ ][ ] = int[5][4];

44.

What is the following code doing?

int [ ] [ ] arrayname;

a)

instantiating an array

b)

declaring an array

c)

instantiating a 2D array

d)

declaring a 2D array

45.

How many times does the following method print a *?

a)

9

b)

6

c)

7

d)

10

46.

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

47.
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");
}
48.
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
49.
a)

200 66 22 7 2

b)

66 22 7 2

c)

200 66 22 2

d)

200 66 22

e)

7

50.

What is the output of the following Java code?

int num = 5;

while (num > 5) {

num = num + 2;

}

System.out.println(num);

(a)  

51.

A while loop has the following format:

a)

while (condition)

{

...

}

b)

while

{

...

}

c)

continue while (condition)

{

...

}

d)

while [condition]

[

...;

]

52.

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

53.

What is the output of the following code snippet?

int income = 150000;
boolean condition = (income >= 100000);
String className = condition ? "First" : "Economy";
System.out.println(className);

a)

150000

b)

100000

c)

First

d)

Economy

54.

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

55.

General format of if-else statement is :

a)

if(condition)

Statement1;

b)

if

Statement1;

else

Statement2;

c)

if(condition)

Statement1;

else

Statement2;

56.

General format of "simple if" statement is

a)

if(condition)

Statement1;

else

Statement2;

b)

if(condition)

Statement;

c)

if

Statement1;

57.

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

58.

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

59.

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

60.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

61.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

62.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

63.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

64.

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

a)

boolean

b)

String

c)

double

d)

int

65.

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

a)

double

b)

String

c)

int

d)

char

66.

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

67.

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

68.

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

69.

Which expression evaluates to false?

a)

15 % 3 < 2

b)

3 * 3 % 2 <= 0

c)

false == false

d)

false == false == false == false

70.

What is the exact output of the following Java statement?


System.out.println(15 / 2);

(a)  

71.

What is the exact output of the following Java statement?


System.out.println(3 + 5.3);

(a)  

72.

What is the exact output of the following Java statement?


System.out.println(22 / 2.0);

(a)  

73.

What is the exact output of the following Java statement?


System.out.println(18 % 7);

(a)  

74.

What is the exact output of the following Java statement?


System.out.println(4 * 3.0);

(a)  

75.

What is the exact output of the following Java statement?


System.out.println(22 / 2.0);

(a)  

76.

What is the exact output of the following Java statement?


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

(a)  

77.

What is the exact output of the following Java statement?


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

(a)  

78.

What is the exact output of the following Java statement?


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

(a)  

79.

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

80.

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

a)

z %= z + 3

b)

z %= 3

c)

z =% 3

d)

z % 3 = z

81.

In a gymnastics or diving competition, each contestant’s score is calculated by dropping the lowest and highest scores and then adding the remaining scores. Write a program that allows the user to enter eight judges’ scores and then outputs the points received by the contestant. Format your output with two decimal places. A judge awards points between 1 and 10, with 1 being the lowest and 10 being the highest. For example, if the scores are 9.2, 9.3, 9.0, 9.9, 9.5, 9.5, 9.6, and 9.8, the contestant receives a total of 56.90 points.

Class name: GymnasticsScoring

Hint: use Arrays.sort() to sort the elements in ascending order

Using of AI tool is NOT allowed

Paste your source in the space provided

4 lines