Final Prepare Flashcards
What is the object-oriented relationship between BufferedReader and Reader?
BufferedReader IS-A Reader
class
The blueprint from which individual objects are created
Object
The root of the class hierarchy. Every class has the object as a superclass. All objects, including arrays, implement the methods of this class
instance variable
Variables within a class but outside any method. These variables are initialized when the class is instantiated.
Instance variables can be accessed from inside any method, constructor or block of that particular class
Subclass
Inherits all the public and protected members of its parent, no matter what package the subclass is in.
If the subclass is in the same package as its parent, it also inherits the package-private members of parent
Primitive vs reference types
Primitive types are basic types of data
- byte, short, int, long, float, double, char
- primitive variables store primitive value
Reference types are instantiable class as well as arrays
- String, Scanner, Random, Die, int[], String[]
- Reference variables store addresses
Java API
- A list of all classes that are part of the Java development kit (JDK)
- Includes all Java packages, classes, and interfaces, along with their methods, fields
Package
Basics of inheritance in Java
Public
Can be accessed from any other class
Private
- The most restrictive access level
- Class and interfaces cannot be private
- Can only access using getter/setter
- A strategy to encapsulate data from the outside world
Polymorphism
Deals with how the program decides which methods it should use, depending on what type of thing it has. That is the ability to treat objects of different types in a similar manner.
Inheritance
When a ‘class’ derives from an existing ‘class’. For example, say we have a Person class, and when our student class inherits from Person class, meaning that student class carries all the public behavior and attributes that a person has.
Interfaces
Used as the parameter type of one or more methods in the class that solve the problem
Overloading
Deals with the idea of having two or more methods in the same class with the same name but different arguments
Override
A method with same name and same parameter exist in both superclass and subclass. Method override can be used to rewrites the functionality of the method is given by superclass, and customize it for its own usage