Object Oriented Flashcards
(18 cards)
Methods that operate on the fields of a class are known as
Instance Methods
What are methods called that are not ‘instance methods’
Class methods or static methods
What can you not do with an abstract class
Cannot instantiate it
In an abstract class what are abstract methods
methods that subclasses must implement
When both the superclass and the subclass define constructors, the process is complicated because __________________ In this case, you must use another of Java’s keywords ________
- both the superclass and the subclass constructors must be executed.
- Super
The Java keyword super has two general forms
The first calls a superclass constructor The second is used to access a member of the superclass that has been hidden by a member of a subclass
If you wish to access a superclass constructor super must ________
Always be the first statement executed inside a subclass constructor
How do you invoke a method or an instance variable of a parent class
super.member
When would you use super.member
when the method/variable names of a subclass hide the method/variable names of the parent class
When a subclass object is created whose constructor is executed first? Is it the parent class or the subclass?
It follows derivation. The parent class first
What are two ways of creating a method that must be overridden
Create a method that throws an exception or prints “Must override” to the screen
Use the Abstract modifier
What keyword prevents someone from overriding a method?
final
What does declaring a method parameter to be ‘final’ do?
prevents the variable from being changed in the method
What does declaring a variable in a method to be final do
prevents it from being assigned a value more than once
What is the difference between the private and the protected access modifier
A private member is accessible only to other members of its class. A protected class is accessible only to other members of its package
How is Java’s protected different from that of C++
In C++ protected means only accessible from subclasses
One interface can extend another interface by use of the word
extends
Prior to JDK 8 an interface could not define any implementation whatsoever. What has changed?
JDK 8 has added a new capability to interface called default method