Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Grade 11 Midterm

Total questions: 23

Worksheet time: 22mins

Name
Class
Date
1.

Fill in the blank: The class used for taking input in Java is called (a)   .

2.

Question: Which method is used to print output in Java?

a)

System.out.input()

b)

System.out.println()

c)

System.out.read()

d)

System.println()

3.

Open-ended: Write a Java code snippet that takes an integer input from the user and prints it to the console.

4 lines
4.

Fill in the blank: To read a string input in Java, we use the method (a)   .

5.

Question: What does System.out.println() do in Java?

a)

Takes input from the user.

b)

Prints a message to the console.

c)

Reads a file.

d)

Terminates the program.

6.

Question: Which of the following correctly reads an integer value from the user?

a)

int num = input.readInt();

b)

int num = input.nextInt();

c)

int num = scanner.read();

7.

Fill in the blank: To import the Scanner class, we use import ______;.

4 lines
8.

Question: What is the output of the following code? If the input is 25, what will be printed?

Scanner sc = new Scanner(System.in);

int num = sc.nextInt();

System.out.println("The number is: " + num);

a)

25

b)

The number is: 25

c)

The number is: num

d)

The number is: null

9.

Question: What will be the output of the following code?

int a = 10;

int b = 5;

System.out.println(a + b);

a)

15

b)

105

c)

5

d)

50

10.

Fill in the blank: The operator used for division in Java is (a)   .

11.

Open-ended: Write a Java code snippet that subtracts two numbers, taken as input, and prints the result.

4 lines
12.

Question: How do you correctly subtract two numbers in Java?

a)

num1 minus num2

b)

num1 -- num2

c)

num1 - num2

d)

subtract(num1, num2)

13.

Question: Which of the following is the correct syntax for multiplication in Java?

a)

num1 * num2

b)

num1 × num2

c)

num1 multiply num2

d)

num1 + num2

14.

Fill in the blank: The result of the expression 12 / 5 in Java (when both are integers) is (a)   .

15.

Question: What is the output of this code?

int num = 7;

num = num + 3;

System.out.println(num);

a)

7

b)

3

c)

10

d)

73

16.

Fill in the blank: The operator used to add two numbers in Java is (a)   .

17.

Question: What will be the output of this Java code?

int num1 = 8;

int num2 = 3;

System.out.println(num1 * num2);

a)

24

b)

5

c)

11

d)

83

18.

Question: What is the output of this code?

int num = 20;

System.out.println(num / 4);

a)

4.0

b)

5

c)

5.0

d)

20

19.

Question: What will this code print?

int a = 15;

a = a - 5;

System.out.println(a);

a)

15

b)

5

c)

10

d)

20

20.

Fill in the blank: The result of 9 / 3 in Java is (a)   .

21.

Open-ended: Write a Java code snippet that multiplies two numbers, taken as input, and prints the result.

4 lines
22.

Fill in the blank: The output of int a = 12; int b = 4; System.out.println(a / b); is (a)   .

23.

Question: What does the following code do?

int a = 7;

int b = -5;

System.out.println(a - b);

a)

Prints 7

b)

Prints 12

c)

Prints 2

d)

Gives an error