Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q441: What will be the result of length([], Len) in Prolog?
- A: Error
- B: Len = 1
- C: Len = 0
- D: None of these
View Answer
C
Q442: The code compress([a, a, b], X). results in:
- A: [a, b]
- B: [a, a, b]
- C: [b]
- D: [a]
View Answer
A
Q443: In the clause lastElement(X, [X]), X represents:
- A: The first element of the list
- B: The middle element
- C: The last element of the list
- D: The entire list
View Answer
C
Q444: A clause in Prolog can be a _______ or a _______.
- A: Rule, fact
- B: Goal, rule
- C: Predicate, variable
- D: Fact, variable
View Answer
A
Q445: Prolog lists are written in the form _______.
- A: {}
- B: []
- C: ()
- D: <>
View Answer
B
Q446: What does the predicate sorted([]) in Prolog signify?
- A: An empty list is sorted
- B: A list is unsorted
- C: A single-element list is sorted
- D: A list with duplicates is sorted
View Answer
A
Q447: Which keyword is used in Prolog to check list membership?
- A: member
- B: includes
- C: find
- D: subset
View Answer
A
Q448: What does the predicate subset([], Y) in Prolog signify?
- A: Empty set is a subset of every set
- B: All elements of Y are subsets
- C: Empty set has no subsets
- D: None of the above
View Answer
A
Q449: In the Zebra puzzle, what does the English man live in?
- A: Blue house
- B: Red house
- C: Green house
- D: Yellow house
View Answer
B
Q450: Which Prolog predicate is used to combine two lists into a union?
- A: member
- B: intersection
- C: union
- D: combine
View Answer
C