unit 9 Flashcards

1
Q

t/f: all getter methods have return types of void

A

false, though true for setter methods

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

what does the capital E stand for in the java quick reference?

A

object type

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

overridden method

A

subclass has same method name AND parameter list, but method does not call exact same thing as in parent class

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

when is super NOT super.?

A

in the constructor, just super()

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

what do you inherit?

A

everything PUBLIC

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

does return type matter in overloading?

A

nah

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

true/false: super must always be the first statement in a constructor

A

true

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

does the statement compile:
Statue eTanseer = new Gargoyle(“eshan”);

where gargoyle is a subclass of statue?

A

ye

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

when is super() implemented?

A
  1. in a constructor, when you have private variables/fields in the superclass which you want to initialize
  2. automatically/implicity, when a class has a parent class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what happens if super is not explicitly called and the superclass has no no-args constuctor?

A

compile error

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

are constructors inherited?

A

NO, thats why we use super and java calls super if you dont

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

when is super called automatically/invisibly?

A

ONLY in constructors

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

in the body of a class you have access to….

A

all the fields within that class

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

to override an object method…

A

you must use type Object as a parameter

same thing with anything else being overriden, must have same object as for method being overriden (i think?)

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

what is an abstract class

A

a class that cannot and should not be instantiated (think pet, cant create a pet w/o subclass)

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

what happens when you declare a subclass object as the type of a superclass?

ex.

statue Eshan = new Gargoyle();

A
17
Q

annotate your questions with arrows showing left to right or right to left and columns and rows and such

A
18
Q

why dont subclasses inherit constructors, even though theyre public?

A

because it must have the same header, and as theyre different classes and constructors are based on class headers, they literally cant have the same constructor header

19
Q

when does java create an automatic no args constructor?

A

ONLY when the superclass/class DOES NOT ALREADY have a constructor

20
Q

How to override method

A

To override an inherited method, the method in the child class must have the same name, parameter list, and return type (or a subclass of the return type) as the parent method. Any method that is called must be defined within its own class or its superclass.

21
Q

if a inherits from b, b inherits crom c, and c inherits from d, check ANY that are true
1. a is the grandparent of b, c, and d
2. d is derived from b
3. b may use public methods that are declared in c
4. c may use public methods that are declared in a
5. a may use public meths that are declared in d

A

3 and 5

22
Q
A