OCPChapter1 REVIEW Flashcards

1
Q

What is overriding?

A

Same method name but same parameter lists

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

What is overloading

A

Same method name but different parameter list like type/numbers

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

Can you have the static word to override? Why or why not?

A

nope. because if you have the static then the method will be hidden

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
What are the three ways that you can fill the blank codes: 
abstract class Cat
{
}
class Lion extends Cat
{
 void clean(){}
}
A
  1. empty (like what)
  2. abstract void clean{}
  3. void clean(){}

Empty cause the abstract class is not required to have any methods in it

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

Can a class be both abstract and final?

A

nope. Because abstract classes is made to be subclassed. but final cannot be subclassed so it defeats the purpose.

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

Page 7 pattern not detected

A

what import question pa

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

Page 7 pattern not detected

A

what import question pa

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

All java classes inherit from what?

A

the Object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Explain why this happens:
HeavyAnimal hippo = new Hippo();
boolean b4= hippo instanceof Object; 
Why is this true?
so if you do null??
A

because that is an object and unless it is null.

It will be false

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

What is annotation?

A

provides extra information about the pgram and it is a type of metadata and used by the compiler and even at runtime
@Override and then u overload then give compile error and you as a programmer will be able to fix it

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

What is toString() used for?

A

print an object.

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