OCPChapter1 REVIEW Flashcards
What is overriding?
Same method name but same parameter lists
What is overloading
Same method name but different parameter list like type/numbers
Can you have the static word to override? Why or why not?
nope. because if you have the static then the method will be hidden
What are the three ways that you can fill the blank codes: abstract class Cat {
} class Lion extends Cat { void clean(){} }
- empty (like what)
- abstract void clean{}
- void clean(){}
Empty cause the abstract class is not required to have any methods in it
Can a class be both abstract and final?
nope. Because abstract classes is made to be subclassed. but final cannot be subclassed so it defeats the purpose.
Page 7 pattern not detected
what import question pa
Page 7 pattern not detected
what import question pa
All java classes inherit from what?
the Object.
Explain why this happens: HeavyAnimal hippo = new Hippo(); boolean b4= hippo instanceof Object; Why is this true? so if you do null??
because that is an object and unless it is null.
It will be false
What is annotation?
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
What is toString() used for?
print an object.