Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Chapter: 23
Q421:
Fill in the blank: In Prolog, the names of all relationships and objects must begin with a __________.
A. lowercase letter
B. digit
C. uppercase letter
D. special character
Correct Answer: A
Chapter: 23
Q422:
Fill in the blank: The Prolog statement rainy(columbo). represents a __________.
A. rule
B. query
C. fact
D. comment
Correct Answer: C
Chapter: 23
Q423:
Fill in the blank: Propositional Logic statements involve connectives such as __________.
A. +, -, *
B. ¬, ∧, ∨, ⇒
C. <, >, =
D. @, &, $
Correct Answer: B
Chapter: 23
Q424:
What is the result of the Prolog query ?- snowy(ayubia). given the facts and rules?
A. yes
B. no
C. error
D. undefined
Correct Answer: A
Chapter: 23
Q425:
What is the output of the Prolog query ?- snowy(columbo).?
A. yes
B. no
C. error
D. C = columbo
Correct Answer: B
Chapter: 23
Q426:
Which of the following is a valid Prolog query?
A. &rainy
B. isa(dog, X)
C. %comment
D. 123variable
Correct Answer: B
Chapter: 23
Q427:
Fill in the blank: In Prolog, the rule snowy(X) :- rainy(X), cold(X). defines snowy(X) as true if both __________.
A. rainy(X) and cold(X) are true
B. rainy(X) or cold(X) is true
C. cold(X) is false
D. none of the above
Correct Answer: A
Chapter: 24
Q428:
What is the role of a predicate in Prolog?
A. A declaration of rules or relations
B. The main goal of a program
C. A variable placeholder
D. An anonymous variable
Correct Answer: A
Chapter: 24
Q429:
Which is an example of a predicate in Prolog?
A. brother(ahmed, chand)
B. father(X, Y)
C. man(symbol)
D. write(arg)
Correct Answer: C
Chapter: 24
Q430:
A Prolog fact contains:
A. Parameters as variables
B. Parameters as constants
C. No parameters
D. Both constants and variables
Correct Answer: B
Chapter: 24
Q431:
In Prolog, the clause brother(X, Y) evaluates as true when:
A. X and Y are both brothers
B. X is older than Y
C. X and Y share the same father
D. X and Y are in the same family
Correct Answer: C
Chapter: 24
Q432:
What type of clause is brother(X, Y):- man(X), man(Y), father(Z, Y), father(Z, X).?
A. Fact
B. Goal
C. Rule
D. Predicate
Correct Answer: C
Chapter: 24
Q433:
How many instances of a goal can exist in a Prolog program?
A. None
B. One
C. Multiple
D. Unlimited
Correct Answer: B
Chapter: 24
Q434:
Which of the following is a valid Prolog goal?
A. length([], Len)
B. brother(X, Y)
C. man(X)
D. All of these
Correct Answer: D
Chapter: 24
Q435:
The truth value of the goal in a Prolog program is considered as:
A. A variable
B. The program’s output
C. A list
D. A clause
Correct Answer: B
Chapter: 24
Q436:
In Prolog, variables are:
A. Strongly typed
B. Loosely typed
C. Immutable
D. Both B and C
Correct Answer: D
Chapter: 24
Q437:
What is the correct syntax for an anonymous variable in Prolog?
A. ?
B. _
C. X
D. Variable_1
Correct Answer: B
Chapter: 24
Q438:
In Prolog, the variable name must:
A. Begin with a digit
B. Begin with an underscore or capital letter
C. Be case-sensitive
D. Always be defined at compile time
Correct Answer: B
Chapter: 24
Q439:
Which of the following is a valid list in Prolog?
A. [a, b, c]
B. [1, [2, 3]]
C. []
D. All of these
Correct Answer: D
Chapter: 24
Q440:
The empty list in Prolog is represented by:
A. [0]
B. ()
C. []
D. empty_list
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now