wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming 1 Final Exam

Total questions: 17

Worksheet time: 35mins

Name
Class
Date
1.



What would be the output of given java syntax?

(a)  

2.

What would be the result?

(a)  

3.
What are the legal indexes for the array ar, given the following declaration:
int[] ar = {2, 4, 6, 8 }
a)
 0, 1, 2, 3
b)
 1, 2, 3, 4
c)
2, 4, 6, 8
d)
 0, 2, 4, 6
4.

For the array:

int stats[3];

What is the range of the index?

a)

0 to 3

b)

0 to 2

c)

1 to 3

d)

0 to 4

5.

What is output by the code? Pretend it says System.out.println

a)

2

b)

3

c)

4

d)

5

e)

6

6.

What does the following code print?

a)

A rectangle of 8 rows with 5 stars per row

b)

A rectangle of 8 rows with 4 stars per row

c)

A rectangle of 6 rows with 5 stars per row

d)

A rectangle of 6 rows with 4 stars per row

e)

Infinite Looo

7.

What is printed as a result of executing the code segment?

a)

1 2 4 8 16 32 64

b)

1 2 4 8 16 32

c)

0 1 2 3 4 5 6

d)

2 4 8 16 32

e)

4 8 16 32 64

8.

What is the output of Java program with SWITCH?

int num=20;

switch(num)

{

case 10: System.out.println("TEN"); break;

case 20: System.out.println("THIRTY");

case 30: System.out.println("TWENTY");

}

a)

TEN

b)

TWENTY

c)

THIRTY

d)

TEN

TWENTY

e)

TWENTY

THIRTY

9.

T && T =

a)

T

b)

F

10.

F || F =

a)

T

b)

F

11.

A while loop has the following format:

a)

while (condition)

{

...

}

b)

while

{

...

}

c)

continue while (condition)

{

...

}

d)

while [condition]

[

...;

]

12.

What would be the result?

(a)  

13.

Which of the following is NOT a data types in java

a)

int

b)

String

c)

number

d)

double

14.

int x = 10;

x = x + 5;

System.out.println(x);


What will be the output?

a)

15

b)

5

c)

55

d)

x5

15.

What would be the result?

(a)  

16.

What would be the result?

(a)  

17.

Use int a for first loop and int b for second loop

4 lines