Font size
WorksheetsProgramming 1 Final Exam
Total questions: 17
Worksheet time: 35mins
What would be the output of given java syntax?
(a)
What would be the result?
(a)
ar, given the following declaration:int[] ar = {2, 4, 6, 8 }0, 1, 2, 31, 2, 3, 40, 2, 4, 6For the array:
int stats[3];
What is the range of the index?
0 to 3
0 to 2
1 to 3
0 to 4
What is output by the code? Pretend it says System.out.println
2
3
4
5
6
What does the following code print?
A rectangle of 8 rows with 5 stars per row
A rectangle of 8 rows with 4 stars per row
A rectangle of 6 rows with 5 stars per row
A rectangle of 6 rows with 4 stars per row
Infinite Looo
What is printed as a result of executing the code segment?
1 2 4 8 16 32 64
1 2 4 8 16 32
0 1 2 3 4 5 6
2 4 8 16 32
4 8 16 32 64
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");
}
TEN
TWENTY
THIRTY
TEN
TWENTY
TWENTY
THIRTY
T && T =
T
F
F || F =
T
F
A while loop has the following format:
while (condition)
{
...
}
while
{
...
}
continue while (condition)
{
...
}
while [condition]
[
...;
]
What would be the result?
(a)
Which of the following is NOT a data types in java
int
String
number
double
int x = 10;
x = x + 5;
System.out.println(x);
What will be the output?
15
5
55
x5
What would be the result?
(a)
What would be the result?
(a)
Use int a for first loop and int b for second loop
