Inner and Abstract Classes & Interfaces Flashcards

1
Q

Java Interface

A
  • a blueprint of a class
  • an abstract type that is used to specify behavior(s)/function(s) that all the classes must implement
  • it has static constants and abstract methods (not method body)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we need a Java Interface?

A

to overcome the problem of multiple inheritances

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

List interface

A
  • provides a way to store the ordered collection
  • it is a child interface of Collection
  • it is an ordered collection of objects in which duplicate values can be stored
  • since List preserves the insertion order, it allows positional access and insertion of elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Vector

A

xxx

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

synchronized

A

xxx

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

What’s wrong with the code below?

List < String > fields = new List < String >;

A

‘List’ is abstract; cannot be instantiated.

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

Explain codes:

ISaveable werewolf = new Monster (“Werewolf”, 20, 40);
System.out.println (((Monster) werewolf).getStrenth());

A

xxx

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

How to create an instance of an inner class?

A

OuterClass.InnerClass reference = outerObject.new InnerClassConstructor()

Gearbox mcLaren = new Gearbox(6);
Gearbox.Gear first = mcLaren.new Gear(1, 12.3);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Inner class

A

it refers to the class that is declared within class or interface

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

Types of Inner Classes

A
  1. Nested/Normal/Regular Inner Class
  2. Method Local Inner Class
  3. Static Nested Class
  4. Anonymous Inner Class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Nested/Normal/Regular Inner Class

A
  • when we declare any named class directly inside a class without a static modifier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly