exam 2 Flashcards

1
Q

“A or B -> C” is in the form of a Horn Clause.
True or False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logic programming is based on lambda calculus.
True or False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

a -> d

c -> b

d -> c

Using the statements above, which of the following statement can be derived using inference rules.

A

a - > d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you write the fact “A parrot is a bird” in predicate calculus?

A

bird(parrot).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

__________________ are statements that are assumed to be true and from which all true statements about natural numbers can be proved.

A

Axioms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The language Curry brings together the advantages of functional and logic programming in a single language.
True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

_________________________ refers to the issue that arises when a variable is unified with a term that contains that variable itself, leading to potentially infinite structures or circular references.

A

Occur-check problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the value of Y in Prolog if you write the following statement:

[X|Y] = [1,2,3,4].

A

[2, 3, 4]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Prolog, any statement that is not known to be true is considered false.
True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Every logical statement can be turned into Horn clauses.
True or False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is implication operator in Prolog?

A

:-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which predicate in Prolog can be used to force backtracking and to find all solutions to a query?

A

fail

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

writenum(l, J) :- num(X),
I =< X,
X =< J,
write(X),
nl,
fail.

For the given Prolog code, writenum(1,10) will go into an infinite loop after X = 10.
True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Prolog queries always have one answer.
True or False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Changing the order of the right-hand side of a clause may cause an infinite loop in Prolog.
True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The cut operator is used to “cut” off parts of the search space, effectively preventing Prolog from backtracking past the point where the cut is encountered. Which of the following is the cut operator?

17
Q

Curry is dynamically typed, Prolog uses strong static typing with type inference,
True or False

18
Q

In logic programming, a statement is proved if all subgoals are eventually eliminated and the empty Horn clause is derived.
True or False

19
Q

Prolog’s search strategy is breadh-first search.
True or False

20
Q

If you have the fact human(bob) in Prolog, the query not(not(human(X))) returns X = bob.
True or False

21
Q

In Java, all classes inherit from the _______________ class by default.

22
Q

Simula is the first purely object-oriented language. Everything in Simula is an object, including numbers and code itself.
True or False

23
Q

What is the output of the following Java code:

String a = new String(“hello”);

String b = new String(“hello”);

System.out.println(a == b);

True or False

24
Q

When there is a method overloading in Java, the method that gets called is always determined at run-time based on the method signature.
True or False

25
Which of the following class does not implement List interface in Java?
HashSet
26
In Java, an interface can extend other interfaces using the extends keyword. True or False
True
27
What is the output of the following code: class A{ public void p(){ System.out.println("1"); } public void q(){ System.out.println("2"); } public void r(){ p(); } } class B extends A{ public void p(){ System.out.println("3"); } } class C extends B{ public void q(){ System.out.println("4"); } } public class QuizMain { public static void main(String[] args) { A a = new C(); a.r(); } }
4
28
Constructors in Java must have a return type of void. True or False
False
29
Java does not support operator overloading. True or False
True
30
Java supports multiple inheritance, meaning a class can inherit from more than one base class. True or False
False
31