0% found this document useful (0 votes)
89 views2 pages

Computer Programmin 1st Periodic Exam

This document contains a 21-question multiple choice exam on computer programming concepts such as loops, conditional statements, and data types in Java. The questions cover topics like the different types of loops (e.g. for, while, do-while), loop termination conditions, nested loops, switch statements, if/else statements, and evaluating basic code snippets. The exam is intended for a Grade 12 Computer Programming class and aims to test students' understanding of fundamental programming logic and syntax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views2 pages

Computer Programmin 1st Periodic Exam

This document contains a 21-question multiple choice exam on computer programming concepts such as loops, conditional statements, and data types in Java. The questions cover topics like the different types of loops (e.g. for, while, do-while), loop termination conditions, nested loops, switch statements, if/else statements, and evaluating basic code snippets. The exam is intended for a Grade 12 Computer Programming class and aims to test students' understanding of fundamental programming logic and syntax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OSMEA COLLEGES

TECHNICAL-VOCATIONAL LIVELIHOOD TRACK


INFORMATION AND COMMUNICATIONS TECHNOLOGY
GRADE 12 COMPUTER PROGRAMMING
1st Periodic Exam

MULTIPLE CHOICE. Do not write anything on this test paper.


- Indicate your answer by writing the letter of the correct answer on your Answer Sheet.

1. Type of loop in java that repeatedly executes a target statement as long as a given condition is
true.
a. for loop b. do-while c. while d. nested for loop
2. This is a repetition control structure that allows you to efficiently write a loop that needs to be
executed a specific number of times.
a. for loop b. do-while c. while d. nested for loop
3. This statement allows us to execute a statement or group of statements multiple times.
a. conditional statement b. break statement c. loop statement d. switch statement
4. This type of loop is guaranteed to execute at least one time
a. for loop b. do-while c. while d. nested for loop
5. When this statement is encountered inside a loop, the loop is immediately terminated and the
program control resumes at the next statement following the loop.
a. conditional statement b. break statement c. loop statement d. switch statement
6. External connecting sockets on the outside of the computer. This is a pathway into and out of
the computer.
a. conditional statement b. break statement c. loop statement d. switch statement
7. This statement allows a variable to be tested for equality against a list of values.
a. conditional statement b. break statement c. loop statement d. switch statement
8. This type of conditional statement consists of a Boolean expression followed by one or more
statements.
a. if-else b. nested if c. if d. if-else if
9. Each value in a switch statement is called a ______, and the variable being switched on is checked
for each case.
a. loop b. case c. switch d. break
10.) Find the output of ff code 11.) Find the output of ff code

int sum = 0, cnt = 1; int cnt = 1;


while ( cnt < 10 ) { while ( cnt <= 20 ) {

sum += cnt;
cnt++; cnt = cnt -1;
} }
System.out.println( sum );
a. syntax error b. no output c. 1 d. 20
a. 15 b. 25 c. 35 d. 45

12.) Find the output of ff code 13.) Find the output of ff code
int sum = 0;
int sum=10; for ( int i = 0; i < 4; i++ ) {
sum +=i;
do-while ( sum <= 10000 ) { for ( int j = i; j < 4; j++ ) {
sum = sum + 10;
} sum += j;
}
a. syntax error b. 20000 c. no output d. 10 }
System.out.println( sum );
Prepared by: Ms. Daisy Jean A. Castillo Subject Teacher
Good luck! God Bless! a. 20 b. 25 c. 26 d. 27
14.) How many times will the following loop 15.) Which of the following for loop does not
get executed? terminate?

int cnt = 1; A. for (int i = 0; i < 100; i=10) { ... }


while ( cnt < 100 ) { B. for (int i = 10; i != 1000; is*=10) { ... }
C. for (int i = 100; i >100; i-=10) { ... }
cnt += 2; D. for (int i = 0; i < 10; i+=1) { ... }

a. 100 b. 0 c. 50 d. 99

16.) What will be the value of sum after the 17.) What is the output of the following
following nested-for loops are executed? program fragment?
for ( int j = 0; j < 5; j++ )
int sum = 0; {
for (int i = 0; i < 10; i+=2) { System.out.print( j + " " );
sum += i; }
for (int j = 2*i; j > 0; j/=2) { System.out.println( );
sum += j;
} a. 0 1 2 3 4 5 b. 0 1 2 3 4
} c. 0 1 2 3 4 5 6 d. j j j j j
a. 105 b. 95 c. 75 d. 55

18.) What must the test be so that the 19.) What must the change be so that the
following fragment prints out the integers 5 following fragment prints out the even
through and including 15? integers 0 2 4 6 8 10?
for ( int j = 5; ________ ; j++ )
{ for ( int j = 0; j <= 10; _______ ){
System.out.print( j + " " ); System.out.print( j + " " );
} }
System.out.println( ); System.out.println( );

a. j<15 b. j<=16 c. j<16 d. j==15 a. j+2 b. j=j+2 c. j++++ d. ++j++

20.) What will the output be of this expression 21.) What will be the output of the following
if the variable x = 13? program?

if (x < 12) { if( 1 > 2 )


System.out.println(The number was too low); {
} System.out.println(" 1 is greater than 2");
}
a. The number was too low else
b. x<12 System.out.println(" 2 is greater than 1");
c. x= 13
d. Nothing will happen a. No output
b. 1 is greater than 2
c. 2 is greater than 1
d. Compilation Error

Prepared by: Ms. Daisy Jean A. Castillo Subject Teacher


Good luck! God Bless!

You might also like