Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Instruction: Encircle the letter of the correct answer.

Part l - Multiple choice

1. What will be the value of x after the following section of code executes

int x = 5;

if (x > 3){

x = x – 2;

else

x = x + 2;

A. x = 3

B. x = 4

C. x = 6

D. x = 8

2. What will be the value of y after the following section of code executes

int y = 4, z = 3;

if (y > 4)

z = 2;

y = y – 1;

else{

z = 1;

y = z;

A. y = 4

B. y = 5

C. y = 1
D. y = 3

3. What will be the value of w after the following section of code executes

int w = 4, q = 3;

if (q > 5){

if (w == 7)

w = 3;

else

w = 2;

else{

if (w > 3)

w = 1;

else

w =0;

A. w=3

B. w=2

C. w=1

D. w=4

4. What will be the value of b after the following section of code executes

int a = 4, b = 0;

if (a < 5){

b = 4;

else if (a < 10){

b = 3;
}

else if (a > 5){

b = 2;

else{

b = 1;

A. b=2

B. b=3

C. b=4

D. b=5

5. What will the following code print?

int color = 3;

switch (color)

case 1:System.out.print("green");break;

case 2:System.out.print("red");break;

case 3:System.out.print("blue");break;

case 4:System.out.print("purple");break;

default:System.out.print("gray");break;

A. green

B. red

C. purple

D. blue

E. gray

6. What will the following code print?


int count = 1;

while (count <= 3){

System.out.print(count + " ");count++;

A. 1 2 3

B. 3 2 1

C. 3 1 2

D. 2 1 3

7. What will the following code print?

int count;

for (count = 4; count > 1; count--){

System.out.print(count + " ");

A. 4 3 2

B. 3 4 2

C. 2 4 3

D. 2 3 4

8. What will be the value of total after the following section of code executes

var total = 10;

total = total == 25 ? total * 2 : total + 20;

A. total=20

B. total=30

C. total=35

D. total=40

9. What will be the value of w after the following section of code executes
int x = 2;

var data = [

{ title: "Star Wars: A New Hope", year: 1977 },

{ title: "Star Wars: The Empire Strikes Back", year: 1980 },

{ title: "Star Wars: Return of the Jedi", year: 1983 }

];

var w = x == 2 ? data[x-1] : data[x-2];

A. w = title: "Star Wars: A New Hope", year: 1977

B. w = title: "Star Wars: The Empire Strikes", year: 1981

C. w = title: "Star Wars: The Empire Strikes Back", year: 1980

D. w = title: "Star Wars: Return of the Jedi", year: 1983

10. What will be the value of x and y after the following section of code executes

int x=20 ,y=30;

x = y == 30 ? (x+20)+y : y == 10 ? (x-20) : x+y;

y = x == 20 ? (y-x)+5 : y == 30 ? (x+y)+5 : 0;

A. x=70, y=15

B. x=50, y=25

C. x=30, y=115

D. x=50, y= -15

11. What will be the value of z after the following section of code executes

int z = 100;

var data = [10,20,10,40,10,50];

array.forEach(data => {

data == 10 ? z++ : z-2;

});

A. z=97
B. z=106

C. z=94

D. z=103

12. What will be the value of q after the following section of code executes

int q = 0 , x = 5;

while(x <=20)

q + 3;

x +5;

A. q=9

B. q=8

C. q=7

D. q=6

13. What will be the value of color after the following section of code executes

const colors = ["Blue", "Red", "Green"];

int i = 1;

string color = "";

while (colors[i]) {

color += colors[i] + ", ";

i++;

A. color=Red, Green

B. color=Blue, Red

C. color=Red, Blue

D. color=Blue, Green
14. What will be the value of day after the following section of code executes

var day;

switch (new Date().getDay()) {

case 0:

day = "Sunday";

break;

case 1:

day = "Monday";

break;

case 2:

day = "Tuesday";

break;

case 3:

day = "Wednesday";

break;

case 4:

day = "Thursday";

break;

case 5:

day = "Friday";

break;

case 6:

day = "Saturday";

A. day = Sunday

B. day = Monday

C. day = Tuesday
D. day = Wednesday

E. day = Thursday

F. day = Friday

G. day = Saturday

15. What will be the value of xyz after the following section of code executes

var xyz = 3.5, qwe = 5.3;

xyz = xyz > 3 ? Math.floor(xyz + qwe) : Math.round(xyz - qwe);

A. xyz = 3

B. xyz = 4

C. xyz = 5

D. xyz = 8

Part ll - SQL Logical Test #16-23

16. Create Students table where we can set the students details and Primary key as
StudentId .(StudentId,LastName,FirstName,YearLevel)

17. Create Subjects table where we can set Subject details and Primary key as SubjectId
and all columns are not nullable.(SubjectId,YearLevel,Name,FieldId)

18. Create Grades table where we can set the grades details and Primary key as FieldId and
all columns are not nullable..(FieldId,SubjectId,PassFail)

With the tables created above:

19. show result of each student's grades in subject and whether they pass/fail.

20. show result for getting the passing rates of each subject.

21-22. Add "Tuazon, Bonn","Escudero, Markelon" where year level is 1 on Students Table

23. Update the YearLevel of "Escudero, Markelon" from 1 to 2;

You might also like