BIG T's Flashcards
(17 cards)
What’s Abstraction
The process of determining the set of data and methods that a class will have
What are two main parts of an object?
It’s properties and methods
What’s a class and object?
A class provides instructions for building an object.
The object is what gets built when the constructor method of the class file is called
What is Polymorphism?
You can have several methods with the same name defined in different classes of a class hierarchy. This is called method overriding
What is an object?
A particular instance of a class
How is a constructor method different?
- Always the same as the class name
- No return type specified
What does static mean?
- Means we don’t have to instantiate an object of the class to use the method
A static variable is a class variable. What does this mean
- Means it is visible to every method in the class
- Just one copy of class variable in memory
- If changed, all the objects will change
How is an abstract method different?
- There is no body code in an abstract method
What’s the difference between method overloading and overriding?
- Overloading: Same method name different parameters. Must be defined in the same class
- Overriding: Same method name and signature. Must be used in seperate instances in the sub classes from a class heirarachy
Can an abstract method be in a non abstract class
NO
Can an interface hold data values
Yes, But by default the values will be constants set as Public, Static and final
- Interfaces can only hold abstract methods
What changed in JDK 1.8?
- Interfaces can now hold methods with default implementation and they can be declared static
What are the two main uses of interfaces?
- Write an abstract method and have a large number of classes implement them
- Multiple Inheritance Stimulation
Can you instantiate and object from the interface?
NO, but the JVM can
What’s an abstract class and when is it created?
- Whenever we create objects of the sub class, JVM will internally create an object of the abstract super class
What must be done for Polymorphism to work?
The objects of the subclasses have to be created and referenced by a variable of the superclass