wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PRA PSPM SC025 ( F01 KML )

Total questions: 24

Worksheet time: 12mins

Name
Class
Date
1.

Based on the java coding, what is the method type used?

a)

Type 1

b)

Type 2

c)

Type 3

d)

Type 4

2.

What is the output of the following code ?

a)

5

b)

0

c)

4

d)

Compilation Error

3.

Which of the following is the definition of sequence?

a)

A sequence of well-defined steps to solve a problem

b)

Performs actions one after another

c)

Performs actions based on a certain condition

d)

Allows a sequence of instructions to be executed repeatedly until a certain condition reached

4.

Which of these is an incorrect array declaration?

a)

int arr[]=new int[5];

b)

int []arr=new int[5];

c)

int arr[]=new int[5];

d)

int arr[]=int [5] new;

5.

What is the output if the diameter of the circle is 12?

a)

452.448

b)

452

c)

113.112

d)

113

6.

What is stored in this array backpack?

String backpack[] = {“Apple”, “Banana”};

a)

Apple

b)

Banana

c)

Apple, Banana

d)

Null

7.

What is the meaning of this coding?


while (num!=-999)

a)

Number cannot be -999

b)

Number can be -999

c)

Number cannot be -999 with condition

d)

Number can be -999 with condition

8.

When you want to make the start point in flowchart, what is the shape used?

a)

Circle

b)

Rectangle

c)

Oval

d)

Square

9.

What will this display?

a)

3, 9, 5

b)

3, 9

c)

3, 9, -5, 5

10.

Which of the following is not a keyword in Java?

a)

Read

b)

Write

c)

start

11.

A Java program was built to verify if the person's age is able to get a golden age discount on a Dayan Market.

Which one is the correct if-else statement to verify if the age passed equal or more than 60?

a)

if(age>=60)

b)

if(age>60)

c)

if(age<60)

d)

if(age<=60)

12.

Cindy was borrowing a book from Veytican Library. She was returning a book late. Calculate the total fine charged to Cindy by library for late book return. The charge is RM0.20 per day. Identify the input, process and output.

a)

Input: RM0.20

Process: calculate total fine charged based on late day

Output: total fine charged

b)

Input: late_day

Process: Calculate total fine charged based on late day

Output: total_fine_charged

c)

Input: Late Day

Process: calculate total fine charged based on late day

Output: Total Fine Charged

d)

Input: total fine charged

Process: calculate total fine charged based on late day

Output: late day

13.

How is Sequence represented in pseudocode?

a)

Each step of the algorithm is explained in a diagram

b)

Each step of the algorithm is written on a line of its own, in sequence

c)

All steps of the algorithm is written on the same line

14.

public static void main (String[] args) {


Coding above refers to which type of basic components of a Java Program?

a)

Class declaration

b)

Body of method main()

c)

Comments

d)

Method main()

15.

A diagram that were used to represent a set of instructions is called:

a)

Shapes

b)

Flowchart

c)

Pseudocode

16.

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

a)

for i in range(0,5)

b)

for i in range(5)

c)

for i in range(5,0,1)

d)

for i in range(0,5,1)

17.

Process: To display message “I LOVE JAVA” 10 times


Output: “I LOVE JAVA”

a)

I LOVE JAVA

b)

null

c)

message

d)

10 message

18.

Method is a collection of statements that are grouped together to perform an operation. There are two types of methods and one of them is the user-defined method. Select the correct statement about that method. (Your answer can be more than one)


i. User-defined methods are built-in methods in Java that are readily available to use for the programmer.


ii. General structure of the method which is the return type, method name and parameter must be defined first before you can call a method.


iii. It is a method that can return a primitive data type such as int and double.


iv. User-defined method is a method that is defined by a programmer.

a)

ii, iii and iv

b)

i, ii and iii

c)

i and iv

d)

ii only

19.

Java class names should always begin with an Uppercase letter and with a number.

a)

True

b)

False

20.

What is the output of the following code?

a)

5

b)

0

c)

4

d)

Compilation Error

21.

Which is the correct rule to write an identifier in the Java language ?

a)

A variable that start with a numeric or number

b)

Use special characters

c)

Use reserved word

d)

First character begin with letter,underscore or a dollar sign

22.

Based on the array above, what is the output ?

a)

Ferrari

b)

BMW

c)

Mercedes

d)

Lambhorgini

23.

The Repetition structure is recommended to handle sentinel-controlled repetition of

a)

While

b)

Do/While

c)

For

d)

Continue

24.

Choose the correct answer :


i. Parameter is variable declarations that is used in method


ii. If a method returns a value, then the method call should be assigned to a variable


iii. You can use method only once

a)

i and ii

b)

i only

c)

ii and iii

d)

i, ii and iii