Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 24
Q441:
What will be the result of length([], Len) in Prolog?
A. Error
B. Len = 1
C. Len = 0
D. None of these
Correct Answer:
C
Chapter: 24
Q442:
The code compress([a, a, b], X). results in:
A. [a, b]
B. [a, a, b]
C. [b]
D. [a]
Correct Answer:
A
Chapter: 24
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
Correct Answer:
C
Chapter: 24
Q444:
A clause in Prolog can be a _______ or a _______.
A. Rule, fact
B. Goal, rule
C. Predicate, variable
D. Fact, variable
Correct Answer:
A
Chapter: 24
Q445:
Prolog lists are written in the form _______.
A. {}
B. []
C. ()
D. <>
Correct Answer:
B
Chapter: 25
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
Correct Answer:
A
Chapter: 25
Q447:
Which keyword is used in Prolog to check list membership?
A. member
B. includes
C. find
D. subset
Correct Answer:
A
Chapter: 25
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
Correct Answer:
A
Chapter: 25
Q449:
In the Zebra puzzle, what does the English man live in?
A. Blue house
B. Red house
C. Green house
D. Yellow house
Correct Answer:
B
Chapter: 25
Q450:
Which Prolog predicate is used to combine two lists into a union?
A. member
B. intersection
C. union
D. combine
Correct Answer:
C
Chapter: 25
Q451:
Fill in the blank: The _____ in the Zebra puzzle owns the dog.
A. Swede
B. Dane
C. Norwegian
D. German
Correct Answer:
A
Chapter: 25
Q452:
Fill in the blank: In Prolog, the function next_to(L1, L2, S) checks if two items are _____.
A. Adjacent
B. Duplicates
C. Identical
D. Sorted
Correct Answer:
A
Chapter: 25
Q453:
What drink is consumed in the middle house in the Zebra puzzle?
A. Coffee
B. Soda
C. Milk
D. Tea
Correct Answer:
C
Chapter: 25
Q454:
Which of the following is a valid definition for the union predicate in Prolog?
A. union([], X, X).
B. union(X, [], []).
C. union([], X, []).
D. union([], [], X).
Correct Answer:
A
Chapter: 25
Q455:
What color is the house to the left of the white house in the Zebra puzzle?
A. Blue
B. Green
C. Red
D. Yellow
Correct Answer:
B
Chapter: 25
Q456:
Who lives in the first house in the Zebra puzzle?
A. English man
B. Swede
C. Norwegian
D. Dane
Correct Answer:
C
Chapter: 25
Q457:
Which Prolog predicate checks for the intersection of two lists?
A. subset
B. union
C. intersection
D. member
Correct Answer:
C
Chapter: 26
Q458:
What is Prolog primarily used for?
A. Game development
B. Writing operating systems
C. Expert systems development
D. Database management
Correct Answer:
C
Chapter: 26
Q459:
Which of the following drug relieves headaches?
A. penicilline
B. aspirin
C. anti-diarrhea
D. bis_cure
Correct Answer:
B
Chapter: 26
Q460:
Which symptom is relieved by "de_congest"?
A. diarrhea
B. severe_pain
C. nasal_congestion
D. headache
Correct Answer:
C