OA Exams

  • California, TX 70240
  • Info@gmail.com
  • Office Hours: 8:00 AM – 7:45 PM
  • web.groovymark@gmail.com
  • December 17, 2024

Question 01

What is a branch in programming?

a) A sequence of statements executed under a certain condition
b) A list of functions in a program
c) A variable declaration
d) A program ending statement

Correct Answer: a) A sequence of statements executed under a certain condition

Explanation: A branch is a sequence of statements in a program that only executes when a specific condition is met, typically within an "if" or "else" block.

Question 02

What is a decision in a flowchart?

a) A process of writing functions
b) A graphical representation of loops
c) A choice between two branches based on a condition
d) A sequence of calculations

Correct Answer: c) A choice between two branches based on a condition

Explanation: In a flowchart, a decision creates two branches, where one branch executes if the condition is true and the other if it is false.

Question 03

What is an if-else branch?

a) A loop with two iterations
b) A branch that always executes
c) A decision structure where one branch executes if the condition is true and the other if false
d) A function call

Correct Answer: c) A decision structure where one branch executes if the condition is true and the other if false

Explanation: An if-else branch allows a program to choose between two paths depending on whether the condition evaluates to true or false.

Question 04

What is the symbol for the equality operator?

a) !=
b) ==
c) >
d) >=

Correct Answer: b) ==

Explanation: The equality operator (==) checks if two values are the same.

Question 05

What is a relational operator?

a) A symbol that assigns values to variables
b) A symbol that relates two values, such as being greater than or less than
c) A loop structure
d) A type of function

Correct Answer: b) A symbol that relates two values, such as being greater than or less than

Explanation: Relational operators compare two values to determine their relationship, such as greater than, less than, or equal to.

Question 06

What does the logical AND operator (&&) do?

a) It returns true when both operands are true
b) It returns true when one operand is false
c) It negates the value of both operands
d) It compares strings

Correct Answer: a) It returns true when both operands are true

Explanation: The logical AND operator (&&) evaluates to true only if both operands are true.

Question 07

What does the logical OR operator (||) do?

a) Returns true only if both operands are false
b) Returns true if at least one operand is true
c) Always returns false
d) Compares two strings

Correct Answer: b) Returns true if at least one operand is true

Explanation: The logical OR operator (||) returns true if either one or both operands are true.

Question 08

What does the logical NOT operator (!) do?

a) It switches a true value to false, and vice versa
b) It multiplies two operands
c) It checks equality between two operands
d) It increments a variable

Correct Answer: a) It switches a true value to false, and vice versa

Explanation: The logical NOT operator (!) inverts the boolean value, turning true into false and false into true.

Question 09

What is a decision sequence in programming?

a) A set of loops
b) A series of actions performed in a set order
c) A variable declaration
d) A condition for terminating a program

Correct Answer: b) A series of actions performed in a set order

Explanation: A decision sequence is a series of conditional actions that follow one another in a predefined order.

Question 10

What are logical operators used for?

a) To perform mathematical calculations
b) To compare boolean values and evaluate to true or false
c) To define functions
d) To declare variables

Correct Answer: b) To compare boolean values and evaluate to true or false

Explanation: Logical operators (like AND, OR, and NOT) are used to evaluate boolean expressions and return true or false.

Question 11

What happens in a ‘while’ loop?

a) The loop executes until the condition is false
b) The loop runs for a fixed number of iterations
c) The loop executes only once
d) The loop executes a function

Correct Answer: a) The loop executes until the condition is false

Explanation: A while loop repeatedly executes the loop body as long as the condition remains true.

Question 12

What is a sentinel value in a loop?

a) A value that continues the loop indefinitely
b) A special value that indicates the end of a list
c) A condition to start the loop
d) A variable used in the loop

Correct Answer: b) A special value that indicates the end of a list

Explanation: A sentinel value is used in loops to mark the end of input or a sequence, signaling the loop to stop.

Question 13

What is a ‘for’ loop used for?

a) To iterate a fixed number of times
b) To execute code conditionally
c) To perform multiplication
d) To repeat code forever

Correct Answer: a) To iterate a fixed number of times

Explanation: A 'for' loop is used when the number of iterations is known beforehand, making it ideal for iterating over arrays or counting.

Question 14

What is a nested loop?

a) A loop inside another loop
b) A conditional statement inside a loop
c) A loop that runs infinitely
d) A loop with two statements

Correct Answer: a) A loop inside another loop

Explanation: Nested loops are loops placed inside the body of another loop, where the inner loop executes completely during each iteration of the outer loop.

Question 15

What is a do-while loop?

a) A loop that first checks the condition before executing
b) A loop that guarantees at least one execution of its body
c) A loop that never ends
d) A loop used to store functions

Correct Answer: b) A loop that guarantees at least one execution of its body

Explanation: A do-while loop executes its body at least once, then checks the condition to determine if further iterations are needed.

Question 16

What is a switch statement?

a) A way to create multiple if-else branches
b) A way to define functions
c) A looping structure
d) A way to declare variables

Correct Answer: a) A way to create multiple if-else branches

Explanation: A switch statement evaluates an expression and executes code based on different possible values of that expression, similar to multiple if-else branches.

Question 17

What is an if-elseif branch used for?

a) To execute a loop
b) To compare variables
c) To detect ranges, with only one branch executing
d) To declare a function

Correct Answer: c) To detect ranges, with only one branch executing

Explanation: If-elseif branches allow a program to test multiple conditions, but only the first true condition's branch is executed.

Question 18

What is an equality operator?

a) A symbol that checks if two values are equal or not equal
b) A symbol that assigns values to variables
c) A loop operator
d) A way to increment variables

Correct Answer: a) A symbol that checks if two values are equal or not equal

Explanation: Equality operators (== and !=) compare two values to check if they are the same or different.

Question 19

What is an implicit conversion in programming?

a) A conversion explicitly requested by the programmer
b) An automatic conversion of one data type to another
c) A function that changes data
d) A type of loop structure

Correct Answer: b) An automatic conversion of one data type to another

Explanation: Implicit conversion occurs automatically when one data type is converted to another, such as from integer to float, without explicit instruction from the programmer.

Question 20

What is a function call?

a) The declaration of a function
b) The execution of a function’s statements by invoking its name
c) A way to declare variables
d) A loop condition

Correct Answer: b) The execution of a function's statements by invoking its name

Explanation: A function call is when a program invokes a function to execute its defined statements.

Complete the Captcha to view next question set.

Tags

Prev Post
WGU D278 Practice Exam Questions – Set 1 – Part 2
Next Post
WGU D278 Practice Exam Questions – Set 2 – Part 2