Quiz 7 Flashcards

1
Q

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();
}

}

3, 4, 2, or 1?

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
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, T/F?

A

False

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

Java does not support operator overloading, T/F?

A

True

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

Constructors in Java must have a return type of void, T/F?

A

False

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

Simula is the first purely object-oriented language. Everything in Simula is an object, including numbers and code itself, T/F?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
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?

A

False

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

Which of the following class does not implement List interface in Java?
HashSet, ArrayList, Vector, or LinkedList?

A

HashSet

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

In Java, an interface can extend other interfaces using the extends keyword, T/F?

A

True

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

Java supports multiple inheritance, meaning a class can inherit from more than one base class, T/F?

A

False

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

In Java, all classes inherit from the ________ class by default.
Map, iterable, list, or object?

A

Object

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