Font size
WorksheetsCS 211 - Midterm Review
Total questions: 30
Worksheet time: 15mins
TRUE && FALSE
TRUE
FALSE
A variable name can contain alphanumeric characters, dollar sign, and...
dash
underscore
comma
semi-colon
This statement immediately terminates the loop if the condition is true.
continue
System.out.println
case
break
In this statement, System.out.println(num + " km is " + met " in meters."); the plus (+) operator was used as…
Addition Operator
Relational Operator
Concatenation Operator
Comparison Operator
Which inputs will make the result of this condition: if((digit >= 48 && digit <= 57)) true?
1, 2, 3, 4
a, b, c, d
A, B, C, D
All of these
Which of the following components of the for loop is executed once?
Condition
Iterator
Initialization
Statement
Which of the following does this symbol = belong to?
Relational Operators
Assignment Operators
Conditional Operators
Logical Operators
Which of the following are relational operators?
>, <, =, !=
<, >, ==, !=
&&, ||, !
+=, ==, -=
Which of the following is == 0?
95/5
95+5
95%5
95-5
This refers to the embodiment of a class.
attribute
methods
object
properties
How will the value 20 be assigned to the variable my_num during initialization?
int my_num == 20;
int 20 = my_num;
int my_num = 20;
int 20 == my_num;
This loop construct is achieved by doing or executing the statement inside the loop, and then checking the condition after.
do-while
while
for
all of these
num+=10 is the same as...
10 = num + 10
num = num + 10
num = 10 + 1
10 = num + num
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.
condition
loop
input
output
How will you display "Hello world" (quotation marks included) in the console?
System.out.println("\"Hello world\"");
System.out.println(""Hello world"");
System.out.println(\"Hello world\");
System.out.println(\""Hello world"\");
This is the magic word to add a package in your program in Java.
Scanner
java.util
import
class Main
Which of the following increases the value of n by 1?
n-
n+
n/
n++
!TRUE
FALSE
TRUE
(TRUE && FALSE) || (TRUE || TRUE)
TRUE
FALSE
It refers to the collection of elements of the same type.
Stack
Tree
Array
Graph
How would you print the sum of first and last elements of the array below?
int[] nums = { 13, 23, 16, 91, 17 };
System.out.print(nums[1] + nums[nums.length+1]);
System.out.print(nums[0] + nums[nums.length-1]);
System.out.print(nums + nums.length);
System.out.print(nums[1] + nums[nums++]);
What set of boolean values will make the following if statement execute its body?
if ( isFound && haveRecords ){
System.out.print(“Mam Fatima is Pretty”);
}
boolean isFound = true, haveRecords = false;
boolean isFound = false, haveRecords = false;
boolean isFound = true, haveRecords = true;
boolean isFound = false, haveRecords = true;
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);
}
}
D
a
n
i
Daniel
Which of the choices below is correct, given the following code:
int[] numbers = new int[5];
numbers evaluates to true if integer is equal to 5
numbers is an instance of integer array with size 5.
numbers is an integer variable that can only store the value 5.
numbers is an array that can contain exactly 4 values.
for(int values : sampleArray);
In this code line, which will be accepting the values from a collection?
values
sampleArray
int
for
The approach in accessing array elements is called...
elementing
indexing
initialization
condition
A way to retrieve and manipulate data when needed.
array
class
methods
variables
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?
idx > length
idx <= array.length-1
idx == length
idx == array.length
for(type _________ : collection)
array
condition
iterator variable
continue
Papasa ka ba sa Midterms sa OOP?
Oo
!FALSE
FALSE || TRUE
TRUE && TRUE
