wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS 211 - Midterm Review

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

TRUE && FALSE

a)

TRUE

b)

FALSE

2.

A variable name can contain alphanumeric characters, dollar sign, and...

a)

dash

b)

underscore

c)

comma

d)

semi-colon

3.

This statement immediately terminates the loop if the condition is true.

a)

continue

b)

System.out.println

c)

case

d)

break

4.

In this statement, System.out.println(num + " km is " + met " in meters."); the plus (+) operator was used as…

a)

Addition Operator

b)

Relational Operator

c)

Concatenation Operator

d)

Comparison Operator

5.

Which inputs will make the result of this condition: if((digit >= 48 && digit <= 57)) true?

a)

1, 2, 3, 4

b)

a, b, c, d

c)

A, B, C, D

d)

All of these

6.

Which of the following components of the for loop is executed once?

a)

Condition

b)

Iterator

c)

Initialization

d)

Statement

7.

Which of the following does this symbol = belong to?

a)

Relational Operators

b)

Assignment Operators

c)

Conditional Operators

d)

Logical Operators

8.

Which of the following are relational operators?

a)

>, <, =, !=

b)

<, >, ==, !=

c)

&&, ||, !

d)

+=, ==, -=

9.

Which of the following is == 0?

a)

95/5

b)

95+5

c)

95%5

d)

95-5

10.

This refers to the embodiment of a class.

a)

attribute

b)

methods

c)

object

d)

properties

11.

How will the value 20 be assigned to the variable my_num during initialization?

a)

int my_num == 20;

b)

int 20 = my_num;

c)

int my_num = 20;

d)

int 20 == my_num;

12.

This loop construct is achieved by doing or executing the statement inside the loop, and then checking the condition after.

a)

do-while

b)

while

c)

for

d)

all of these

13.

num+=10 is the same as...

a)

10 = num + 10

b)

num = num + 10

c)

num = 10 + 1

d)

10 = num + num

14.

In computer programming, they are used to repeat a block of code. For instance, if you want to show a message 100 times, then rather than typing the same code 100 times, they can be used.

a)

condition

b)

loop

c)

input

d)

output

15.

How will you display "Hello world" (quotation marks included) in the console?

a)

System.out.println("\"Hello world\"");

b)

System.out.println(""Hello world"");

c)

System.out.println(\"Hello world\");

d)

System.out.println(\""Hello world"\");

16.

This is the magic word to add a package in your program in Java.

a)

Scanner

b)

java.util

c)

import

d)

class Main

17.

Which of the following increases the value of n by 1?

a)

n-

b)

n+

c)

n/

d)

n++

18.

!TRUE

a)

FALSE

b)

TRUE

19.

(TRUE && FALSE) || (TRUE || TRUE)

a)

TRUE

b)

FALSE

20.

It refers to the collection of elements of the same type.

a)

Stack

b)

Tree

c)

Array

d)

Graph

21.

How would you print the sum of first and last elements of the array below?

int[] nums = { 13, 23, 16, 91, 17 };

a)

System.out.print(nums[1] + nums[nums.length+1]);

b)

System.out.print(nums[0] + nums[nums.length-1]);

c)

System.out.print(nums + nums.length);

d)

System.out.print(nums[1] + nums[nums++]);

22.

What set of boolean values will make the following if statement execute its body?

if ( isFound && haveRecords ){

System.out.print(“Mam Fatima is Pretty”);

}

a)

boolean isFound = true, haveRecords = false;

b)

boolean isFound = false, haveRecords = false;

c)

boolean isFound = true, haveRecords = true;

d)

boolean isFound = false, haveRecords = true;

23.

What will be the output of the following code?

public class Main {

     public static void main (String[] args) {

      char myCharacter = "Daniel".charAt(3);

         System.out.print(myCharacter);

    }

  }

a)

D

b)

a

c)

n

d)

i

e)

Daniel

24.

Which of the choices below is correct, given the following code:

int[] numbers = new int[5]; 

a)

numbers evaluates to true if integer is equal to 5

b)

numbers is an instance of integer array with size 5.

c)

numbers is an integer variable that can only store the value 5.

d)

numbers is an array that can contain exactly 4 values.

25.

for(int values : sampleArray);

In this code line, which will be accepting the values from a collection?

a)

values

b)

sampleArray

c)

int

d)

for

26.

The approach in accessing array elements is called...

a)

elementing

b)

indexing

c)

initialization

d)

condition

27.

A way to retrieve and manipulate data when needed.

a)

array

b)

class

c)

methods

d)

variables

28.

Suppose, char[] cutie= {'D', 'a', 'n', 'i', 'e', 'l'};. What will be the appropriate condition to use in the loop to display all the elements of the given array?

a)

idx > length

b)

idx <= array.length-1

c)

idx == length

d)

idx == array.length

29.

for(type _________ : collection)

a)

array

b)

condition

c)

iterator variable

d)

continue

30.

Papasa ka ba sa Midterms sa OOP?

a)

Oo

b)

!FALSE

c)

FALSE || TRUE

d)

TRUE && TRUE