wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

BSCS 3-5: PPL Final Quiz - 1-28-2025

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.

Which of the following is an example of an explicit sequence control structure?

a)

Sequential execution of statements in the order they are written

b)

Use of parentheses in mathematical expressions to specify the order of operations

c)

Built-in rules of precedence in a high-level programming language

d)

Automatic function calls in functional programming languages

2.

Consider the following expression: A = B + D / K. What would be the output if the language adheres strictly to implicit sequence control without parentheses? Assuming: B = 10, D = 20, K = 5

a)

6

b)

14

c)

18

d)

50

3.

Which of the following best demonstrates a postfix (reverse Polish) notation for the expression (A + B) * C?

a)

* + A B C

b)

A B + C *

c)

C * A B +

d)

+ A B C *

4.

In a programming language like Java, which of the following scenarios involves prefix notation?

a)

A++;

b)

A = A + 1;

c)

A += B;

d)

++A;

5.

What will be the output of the following Java code? (see the image)

a)

17

b)

16

c)

15

d)

Compilation Error

6.

Which of the following control structures is least dependent on sequence control?

a)

If-Else statements

b)

Loops

c)

Switch-case structures

d)

Recursive function calls

7.

What is the primary benefit of using prefix or postfix notations in certain languages like Java for increment or decrement operations?

a)

Allows efficient evaluation of expressions without ambiguity

b)

Eliminates the need for operator precedence

c)

Simplifies debugging

d)

Enhances readability of expressions

8.

Which of the following scenarios correctly describes the concept of functional composition in sequence control?

a)

Assigning the output of one function to multiple variables

b)

Replacing a variable value using an explicit sequence

c)

Using nested function calls to define a computation

d)

Writing multiple statements sequentially within a block

9.

For the infix notation A * (B + C), what would be the equivalent prefix notation?

a)

A B C + *

b)

* + B C A

c)

* A + B C

d)

A * + B C

10.

Which of the following statements is true about implicit sequence control?

a)

It requires the programmer to manually specify the order of execution

b)

It is automatically determined by the rules of the programming language

c)

It overrides any parenthesized expressions

d)

It is used only in machine or assembly languages

11.

Which of the following best describes the purpose of pattern matching in Prolog?

a)

Determining the validity of arithmetic expressions

b)

Calculating mathematical operations using logical rules

c)

Matching variables to predefined templates and assigning values

d)

Replacing recursive functions with iterative loops

12.

In the context of unification in Prolog, which of the following queries will succeed given the database facts parent(john, mary). and parent(mary, susan)?

a)

parent(mary, X)

b)

parent(X, john)

c)

parent(susan, mary)

d)

parent(john, X), parent(X, susan)

13.

Which of the following is an example of backtracking in a logical programming language like Prolog?

a)

Searching for all possible matches for a query and undoing partial results if no match is found

b)

Repeatedly iterating over a list to calculate the sum of its elements

c)

Recursively defining a factorial function

d)

Matching a regular expression to a string

14.

Which of the following statements about structured sequence control is true?

a)

It relies heavily on the use of unconditional goto statements

b)

It treats individual statements as single units for execution

c)

It emphasizes hierarchical and modular control structures like loops and conditionals

d)

It does not support compound statements within iteration structures

15.

Consider the following Java code. What will be printed?

a)

2

b)

3

c)

4

d)

5

16.

Which statement is an example of a conditional sequence control structure?

a)

while (x > 0) { x--; }

b)

if (x > 0) { System.out.println(x); }

c)

int x = 5; x = x + 1;

d)

for (int i = 0; i < 10; i++) { System.out.println(i); }

17.

In a program using iteration, which of the following demonstrates a compound statement in the loop body?

a)

for (int i = 0; i < 5; i++) System.out.println(i);

b)

do { System.out.println("Hello!"); } while (false);

c)

int sum = 0; for (int i = 1; i <= 10; i++) sum += i;

d)

while (x > 0) { x--; y += x; }

18.

What is the main difference between an unconditional goto and a conditional goto statement?

a)

Unconditional goto can only be used inside loops

b)

Conditional goto is controlled by a logical expression, while unconditional goto is not

c)

Conditional goto always transfers control to the end of a block

d)

Unconditional goto is supported only in structured programming languages

19.

Which of the following correctly demonstrates a backtracking scenario?

a)

A program uses a for loop to iterate over an array

b)

A recursive function tries all paths in a maze until the destination is found

c)

A switch-case statement evaluates different cases based on a variable’s value

d)

A while loop decrements a value until it becomes zero

20.

Which of the following operations demonstrates explicit sequence control in a high-level language?

a)

Using parentheses to override operator precedence in an arithmetic expression

b)

Writing a function to calculate the sum of two numbers

c)

Declaring a variable before assigning it a value

d)

Passing arguments by value in a function call