wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

pra PSPM SC025 (F02 KML)

Total questions: 24

Worksheet time: 15mins

Name
Class
Date
1.

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)  

2.

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

a)

positive

b)

negative

c)

zero

d)

all above

3.

What is the value stored in variable p after the following statements are executed?

p=7/2+3

a)

13.5

b)

6.5

c)

1.4

d)

p

4.
a)

Selection

b)

Sequence

c)

Repetition

d)

Interaction

5.

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)

a)

The program will loop indefinitely

b)

The value of the number will be printed exactly 1 time

c)

The while loop will never get executed

d)

The value of number will be printed exactly 5 times

6.

Which statement is correct about selection?

a)

Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied.

b)

Perform one or more actions repeatedly while a certain condition is true.

c)

Performs actions based on certain conditions.

d)

Performs statements one after another in sequence.

7.

Which statement is correct about sentinel?

a)

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

b)

a non-special value in the context of an algorithm.

c)

a data structure consisting of a collection of elements (values or variables).

d)

the main logical structure of algorithms or programs.

8.

The first and the last elements of an array declared as scores[10] is…

a)

scores[0], scores[9]

b)

scores[1], scores[11]

c)

scores[4], scores[3]

d)

score[0], score[9]

9.

If the method does not return a value, its return type is…

a)

int

b)

double

c)

void

d)

char

10.

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] + " ");

}

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

1 2

d)

1 2 3

11.

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?

a)

Good Morning

b)

"Geeks!"

c)

How are you all?

d)

All above

12.

What kind of instructions are used to do a repetitive task?

a)

A function

b)

A condition

c)

A loop

d)

An event

13.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

do-while loop

b)

for

c)

for-each

d)

while

14.

Based on the diagram, is the coding for sentinel-controlled repetition true or false?

a)

TRUE

b)

FALSE

15.

Aira is washing clothes. In which stage of IPO cycle she is in?

a)

Input

b)

Process

c)

Output

16.

What is pseudocode?

a)

A way of describing a set of instructions in text form

b)

A diagrammatic representation of a set of instructions

c)

A specific programming language that all computers use

17.

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?

a)

Prime

b)

NOT Prime

18.

State the difference between method case 1 and case 2?

(a)  

19.

Consider the following declaration:

Double salary[10];


The array size is...

a)

10

b)

9

c)

0

d)

None above

20.

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?

a)

Line 1

b)

Line 8

c)

Line 10

d)

Line 4

21.

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

a)

Counter-controlled

b)

Sentinel-controlled

22.

In the array 'names("John", "Ali", "Sarah")', what is the value of element names(2)?

a)

John

b)

Ali

c)

Sarah

23.

What are the two (2) types of Java methods?

a)

Standard Library Methods

b)

User Library Methods

c)

User-defined Methods

d)

Standard-defined Methods

24.

What is printed when the following code executes and x equals 4 and y equals 3?

a)

First case

b)

second Case

c)

first case

d)

2nd case