wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

ITC C105 Final Term Examination

Total questions: 36

Worksheet time: 18mins

Name
Class
Date
1.

Mia has a basket of apples. Every time she gives away an apple, she subtracts 1 from the total number of apples in her basket. What do you call the action of subtracting 1 from a variable?

a)

Incrementing

b)

Resetting

c)

Decrementing

d)

Digesting

2.

During a coding workshop, Noah is learning about different escape characters in programming. He comes across a question about newline characters. Which of the following is the newline character?

a)

\n

b)

\t

c)

\r

d)

\0

3.

Michael is keeping track of his savings. Every time he saves a dollar, he adds 1 to his total savings. What do you call that action?

a)

Resetting

b)

Incrementing

c)

Decrementing

d)

Digesting

4.

Isla is learning how to declare variables in her programming class. She wants to know which of the choices correctly declares variable X with an "JRU" of string data type.

a)

String X=JRU

b)

String X='JRU'

c)

String X="JRU"

d)

String X="JRU";

5.

During a coding workshop, Isla is trying to teach her classmates how to add comments in Java. She asks them, "which of the following is the correct syntax for commenting in Java?"

a)

# Enter Comments Here

b)

// Enter Comments Here

c)

/* Enter Comments Here **

d)

' Enter Comments Here **

6.

William is organizing a small event and needs to collect feedback from his guests. He decides to ask for their opinions on four different aspects of the event. He initializes a variable to keep track of the total feedback score and sets up a loop to gather inputs from his guests. The code snippet below shows how he plans to do this:

int sum=0, n;

for (int j = 0; j <= 3; j++) {

n = num.nextInt();

sum = sum + n;

System.out.print(sum); }

a)

5

b)

3

c)

4

7.

In a software development project, Jackson needs to decide between two different approaches to implement a feature. He can either use a straightforward method or a more complex one. This decision-making process in Java is implemented using ____.

a)

sequential statements

b)

for loops

c)

if...else statements

d)

if statements

8.

Grace is working on a small project where she needs to keep track of some important values. She writes the following declarations in her code:

int num = 763;

double x = 658.75;

String str = "Java Program.";

How many variables does Grace declare in this snippet?

a)

3

b)

one

c)

2

d)

zero

9.

Abigail is organizing a charity event and needs to print "Thank You" messages for each of the 19 donors. She decides to use a loop to print these messages. In her code, which part of the for loop below is the initial expression?

for (i = 1; i < 20; i++)

System.out.print("Thank You");

a)

i = 1;

b)

i++;

c)

i < 20;

d)

int i;

10.

Emma is working on a project that involves different types of data formats. She needs to choose a data type that can only accept/output decimal format. Which of the following choices should she select?

a)

integer

b)

float

c)

character

d)

one of the Choices

11.

During a coding workshop, Abigail is learning about different operators used in programming. She comes across several symbols and needs to identify which one is not a logical operator. Which of the following is not a logical operator?

a)

|

b)

&

c)

=

d)

!

12.

Aria is working on a Java program where she has the following variable declarations: int num = 763; double x = 658.75; string str = "Java Program."; What will be the output when she executes the following statement? System.out.print( num + x + str );

a)

Java Program

b)

63 658.75 Java Program

c)

num x str

d)

No output

13.

Which in the code is the loop condition expression in the for loop? for (i = 1; i < 20; i++) if(i%10) System.out.print("Hello World"); System.out.print("|");

a)

i++

b)

i<10

c)

i<20

d)

i%10

14.

Arjun is conducting an experiment where he counts the number of times he can press a button in a loop. He starts with a count of 0 and continues pressing the button until he reaches 5. Each time he presses the button, he notes down the current count and the count after pressing it again. What is the output of the following Java code snippet that represents Arjun's experiment? int i = 0; for (; i < 5; ++i) System.out.print( i + "-" + i++ );

a)

0-3-2-5-4

b)

103254

c)

0-2-24-4

d)

002244

15.

How many times will the following snippets of code below print "Welcome to Java"? int ctr = 0; while ( ctr < 10 ) { System.out.println("Welcome to Java"); ctr++; }

a)

11

b)

10

c)

1

d)

No Output

16.

Aria is trying to understand a simple Java program. She writes the following code: int num = 10; while (num > 10){ num = num - 2; System.out.println(num); }

What will be the output of Aria's code?

a)

No output

b)

8

c)

10

d)

0

17.

Mia is planning a party and has 3 balloons. She also has 6 party hats. If the number of balloons is less than 8 and the number of party hats is equal to 2, she decides to buy 4 more balloons for each party hat. How many balloons will Mia have at the end of her planning?

a)

3 6

b)

12 6

c)

0 2

d)

5 2

18.

Suppose that Zoe has 5 apples and Samuel has 6 apples. system.out.print("Sum of " + Zoe + "'s apples and " + Samuel + "'s apples = " + (Zoe + Samuel)); What is the output of the following Java statement?

a)

Sum of Zoe's apples and Samuel's apples = 11

b)

Sum of Zoe's apples and Samuel's apples =11

c)

Sum of apples = 11

d)

Sum of Zoe's apples and Samuel's apples = 10

19.

Abigail is playing a game where she starts with a score of 7 points. She has a flag called 'found' that is initially set to false. In each round of the game, she checks her score and prints it out. If her score is 2 or less, she sets the flag 'found' to true. Otherwise, she subtracts 5 points from her score. She continues playing as long as her score is greater than 0 and the flag 'found' is false. What will be the output of her game?

a)

7 2

b)

7

c)

7 5

d)

2

20.

Isla is telling her friend about her age. She says: system.out.print("20"); system.out.print("is"); system.out.print("Andrei"); system.out.print("'s age.");

a)

20isAndrei's age.

b)

20 is Andrei's age.

c)

20is Andrei's age.

d)

20 isAndrei's age.

21.

Imagine Mia is trying to decide whether to go out for ice cream or stay home. She has $10 to spend. If the cost of ice cream is more than $15, she will treat herself to a movie instead. Otherwise, she will buy ice cream and spend her money. What will Mia do?

a)

10

b)

15

c)

0

d)

5

22.

In a small town, there is a rule for determining the number of apples a person can collect based on their age. If a person is older than 5 years, they can collect 1 apple. If they are younger than 5 years, the rule is as follows: if they are younger than 3 years, they can collect 2 apples; otherwise, they can collect 3 apples. If they are exactly 5 years old, they can collect 4 apples. Based on this rule, how many apples can Elijah collect if he is 3 years old?

a)

3

b)

2

c)

4

d)

1

23.

Isla is collecting the number of apples she picked from a tree. She starts with 0 apples and picks 1 apple on the first day, then continues to pick one additional apple each day. After picking apples for 5 days, she wants to calculate the average number of apples she picked per day.

int sum = 0, x = 1; double average = 0.0; do { sum = sum + x; x++; average = sum / 3.00; } while (x <= 5); System.out.print("The computed average is " + average);

a)

The computed average is 3.0

b)

The computed average is 5

c)

The computed average is 5.5

d)

None of the choices

24.

Kai is counting the number of lines he has written in his notebook. He starts with 1 line. While the number of lines is less than or equal to 5, he adds a new line and says out loud, "Line " followed by the current number of lines he has written. How many lines will he say out loud?

a)

Line 1 2 3 4 5

b)

Line 2 3 4 5 6

c)

Line 2

d)

Line 6

25.

Mia is collecting scores from her friends in a game. Suppose the scores are: 4, 7, 12, and -9. What is the total score after Mia adds them up using the following Java code? int sum = 0; int n; for (int j = 0; j <= 3; j++) { n = num.nextInt(); sum = sum + n; } System.out.print(sum);

a)

14

b)

41

c)

-9

d)

None of the choices

26.

What output will be displayed if N = 10? int N; switch (N % 3) { case 0: System.out.print("Milani Mayaman"); break; case 1: System.out.print("Arlene Mae"); break; case 3: System.out.print("Meanne Maganda"); break; default: System.out.print("Richard Gwapo"); }

a)

Arlene Mae

b)

Leanne Maganda

c)

Richard Gwapo

d)

Milani Mayaman

27.

Jackson is counting the number of apples he has. He starts with 10 apples and keeps counting until he reaches 10. After counting, he decides to divide the total number of apples he has by 2. What is the output of his counting?

a)

prints 10 then 5

b)

prints 0

c)

prints 10 only

d)

prints 50

28.

Abigail has two baskets of apples. In the first basket, she has 5 apples, and in the second basket, she has 10 apples. If the number of apples in the first basket is less than the number of apples in the second basket, she decides to share the total number of apples with her friend. Otherwise, she will keep the difference in the number of apples for herself.

a)

5

b)

15

c)

-5

d)

10

29.

Michael is planning a small party. He decides to invite 4 friends and each friend brings 3 snacks. He wants to know how many snacks he will have in total after adding 3 more snacks he bought himself. Calculate the total number of snacks.

a)

10

b)

12

c)

15

d)

7

30.

In a programming class, Olivia is learning about different control structures in Java. During a discussion, her instructor asks the class to identify which of the following statements is true about the switch statement in Java.

a)

It can only evaluate integer values.

b)

It can evaluate boolean expressions.

c)

It can evaluate strings since Java 7.

d)

It must have a default case.

31.

Oliver is developing a simple calculator program. He wants to implement a function that adds two numbers together. Which of the following code snippets correctly represents the addition operation?

a)

result = num1 / num2;

b)

result = num1 * num2;

c)

result = num1 - num2;

d)

result = num1 + num2;

32.

During a programming class, Sophia is learning about arrays. She needs to find out how many elements are in an array named 'scores'. If 'scores' contains 5 elements, what will be the output of the following code:
System.out.print(scores.length);

a)

0

b)

None of the choices

c)

4

d)

5

33.

In a game, Liam has a score of 50 points. If he scores 10 more points for each level he completes, how many points will he have after completing 3 levels?

a)

60

b)

70

c)

90

d)

80

34.

Lucas is writing a Java program to calculate the area of a rectangle. He defines the length as 5 and the width as 3. What will be the output when he executes the following code? int length = 5; int width = 3; int area = length * width; System.out.print(area);

a)

5

b)

8

c)

15

d)

3

35.

Chloe is trying to find the maximum number from a list of integers: 3, 7, 2, and 9. She uses the following code snippet: int[] numbers = {3, 7, 2, 9}; int max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } System.out.print(max);

What will be the output of Chloe's code?

a)

7

b)

3

c)

9

d)

2

36.

Oliver is learning about loops in Java. He writes a code snippet to print numbers from 1 to 5. The code is as follows: for (int i = 1; i <= 5; i++) { System.out.print(i + " "); } What will be the output of this code?

a)

5 4 3 2 1

b)

1 2 3 4 5 6

c)

1 2 3 4 5

d)

1 2 3 4 5