Font size
Worksheetspra PSPM SC025 (F02 KML)
Total questions: 24
Worksheet time: 15mins
The program will display "A" if the mark entered is greater or equal to 80 or "B" if the mark entered is between 70 to 79.
What's the output?
(a)
Determine whether the number -18 keyed in by the user is ”positive”, “negative”, or “zero"
Start
Read number
If(number > 0 )
Print “positive”
Else if(number < 0)
Print “negative”
Else
Print “zero”
Endif
Stop
positive
negative
zero
all above
What is the value stored in variable p after the following statements are executed?
p=7/2+3
13.5
6.5
1.4
p
Selection
Sequence
Repetition
Interaction
What is the result of executing the following code?
The code :
Number = 5
While number z <= 5
If number < 5
Number = number + 1
Print (number)
The program will loop indefinitely
The value of the number will be printed exactly 1 time
The while loop will never get executed
The value of number will be printed exactly 5 times
Which statement is correct about selection?
Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied.
Perform one or more actions repeatedly while a certain condition is true.
Performs actions based on certain conditions.
Performs statements one after another in sequence.
Which statement is correct about sentinel?
a special value in the context of an algorithm that uses its presence as a condition of termination, typically in a loop or recursive algorithm
a non-special value in the context of an algorithm.
a data structure consisting of a collection of elements (values or variables).
the main logical structure of algorithms or programs.
The first and the last elements of an array declared as scores[10] is…
scores[0], scores[9]
scores[1], scores[11]
scores[4], scores[3]
score[0], score[9]
If the method does not return a value, its return type is…
int
double
void
char
What will be the output of the following Java program?
class Output
{
public static void main(String[] args)
{
int arr[ ] = {1,2,3,4,5} ;
for (int i=0 ; i<arr.length - 2; i++)
System.out.println(arr [i] + " ");
}
}
1 2 3 4 5
1 2 3 4
1 2
1 2 3
public class Gfg {
public static void main(String[] args)
{
System.out.println("Good Morning \"Geeks!\" How are you all? ");
}
}
What is the output for the coding above?
Good Morning
"Geeks!"
How are you all?
All above
What kind of instructions are used to do a repetitive task?
A function
A condition
A loop
An event
Which type of loop is best known for its boolean condition that controls entry to the loop?
do-while loop
for
for-each
while
Based on the diagram, is the coding for sentinel-controlled repetition true or false?
TRUE
FALSE
Aira is washing clothes. In which stage of IPO cycle she is in?
Input
Process
Output
What is pseudocode?
A way of describing a set of instructions in text form
A diagrammatic representation of a set of instructions
A specific programming language that all computers use
The flowchart below is an algorithm to determine whether a number input by the user is a prime number or not.
What is the output if the number = 12?
Prime
NOT Prime
State the difference between method case 1 and case 2?
(a)
Consider the following declaration:
Double salary[10];
The array size is...
10
9
0
None above
Java programming below cannot run.
1. import java.util.Scanner;
2. public class Area{
3. public static void main(String[] args) {
4. Scanner sc = new Scanner(System.in);
5. int length = 5;
6. int width = 7;
7.
8. int area = length*width;
9.
10. System.out.println("Area of Rectangle: "+area)
11.
12. }
13. }
Which line causes an error?
Line 1
Line 8
Line 10
Line 4
Which types of Repetition Control Structure are below?
Start
input num
while num not equal to 0
if num>0
print num
end if
input num
end while
Stop
Counter-controlled
Sentinel-controlled
In the array 'names("John", "Ali", "Sarah")', what is the value of element names(2)?
John
Ali
Sarah
What are the two (2) types of Java methods?
Standard Library Methods
User Library Methods
User-defined Methods
Standard-defined Methods
What is printed when the following code executes and x equals 4 and y equals 3?
First case
second Case
first case
2nd case
