2110 Flashcards

1
Q

Does an abstract class need to be instantiated?

A

No - it just defines variables t methods these methods can
Also be abstract

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

Do subclasses of an abstract class need to inherit variables & methods of their superclass?

A

Yes

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

Which class type i just a header and no body?

A

An abstract class

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

Abstract class syntax

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

What is an interface

A

Just a collection of method declaration • no data no body

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

How does a class implement an interface

A

It guarantees to use all the methods! Therefore an interface enforces an API in software design

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

Interface syntax

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

How is java  Standard library organized?

A

In one large class hierarchy where the object class is the parent of all classes. every single class implicitly extends the object class

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

Three pillars of object oriented programs

A

Encapsulation, inheritance and polymorphism

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

Define encapsulation

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

Define iwhentance

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

Define polymorphism

A

The ability Of one object to be treated, used like another this works for objects in the inheritance hierarchy

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

Can me use a reference of a superclass type to refer to an object of its subclass type

A

Yes

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

What allows us to place objects from different steps within a class hierarchy into the same array?

A

Polymorphism

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

Does polymorphism work bottom up in a class hierarchy?

A

No! Only top down

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

What is the instanceOf operator?

A

Used to keep track of what type of object is being referred to by a variable

. X instanceof Y returns true if X refers to an object of type Y or a subclass (any number of levels down) of Y.

17
Q

What is casting? In the context of class hierarchy

A

Changing the type Of a variable (can be risky bc precision loss)

In the context of a class hierarchy it only works downwards

18
Q

Can casting be done in reverse? Can we use the reference of a subclass type to refer to an object of a superclass type

A

Yes but also risky

19
Q

Encapsulation

A

Defining objects (this is done within class files)

20
Q

The two main components of an object

A

Variable declaration and methods

21
Q

Mutator / accessor methods

A

Setters & getters

22
Q

This keyword

A

Used to distinguish the instance variable from the method parameter

23
Q

In method overloading WHAT needs to be different it the name is the same?

A

Its signature (this means types order of its input parameters)

24
Q

Can constructors be overloaded?

A

Yes

25
Q

Static methods

A

Can be used not on an object

className.staticMethodName(parameters);

The class name can be ignored if its called from the class

All methods used in procedural programming are static

26
Q

Instance variables

A

Each object gets its version of this variable