OCP learning Flashcards

1
Q

may an abstract class have methods or fields declared static?

A

Yes

an abstract class may have methods or fields declared static

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

can the abstract keyword be applied to a field?

A

the abstract keyword can be applied to a class or a method but not to a field

–> no abstract variables

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

an abstract class can be derived from a concrete class?

A

an abstract class can be derived from a concrete class! Although the language allows it, it is not a good idea to do so.

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

wrapper classes –> final or not?

A

wrapper classes –> final class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • which kind of class cannot be extended?

- which kind of method cannot be overridden?

A

final and static class / methods

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

method of Final class –> final or not?

A

all methods of a final class are implicitly FINAL

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

what is blank final?

A

If a variable declaration defines a variable as final but did not initialize it, then it is referred to as blank final.

You need to initialize a blank final all the constructors you have defined in the class; otherwise the compiler will complain.

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

final parameters –> can be?

A

the keyword final can even be applied to parameters. The value of a final parameter cannot be changed once assigned.

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

meaning of final keyword:

  1. primitive
  2. object
A
  1. primitive –> value
  2. object –> refers to the object reference, not its state.

–> can change the internal state of the passed final object, but you cannot change the reference itself.

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