Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
26 Cards in this Set
- Front
- Back
- 3rd side (hint)
Java Class |
A Template that describes state and behavior of the object of its type |
|
|
Java Object |
Instance of the Class having its own state and access to all behaviors |
|
|
State (Instance Variables) |
Values assigned to Object instance |
|
|
Behavior (Methods) |
Methods are where logic of class is stored and where the real work is done |
|
|
Inheritance |
Concept in java which allows code of one class to be used in another class. 1. Single, Multilevel, hierarchical, Multiple, hybrid 3. hybrid is possible with interfaces and not with classes |
|
|
Interface |
100 percent abstract superclass that defines methods that a subclass must support but not how they must be supported |
|
|
Legal identifiers |
1. $ and _ works 3. Java keyword cannot be used 4. Case sensitive |
4 points |
|
Conventions |
Class and interface - first letter capital (camel case) and interfaces are adjectives (runnable etc.) Methods and variables - first letter lowercase and camelcase Constants - All Uppercase and underscore as separators (SCHOOL_NUM) |
how you write them ? |
|
Class declaration and Modifiers |
Access Modifiers - Public, ptivate, Protected Non-Access Modifiers - strictfp, final,abstract |
|
|
Default Access |
1. Has no modifier preceding it. 2. Package level access. 3. default class can only be used by class in same package |
|
|
Public Access |
1. public keyword gives access to all classes from all packages 2. Diff. packages still needs to import a package to access public class. |
|
|
strictfp |
any method or code with strictfp keyword will conform to IEEE754 standard for floating points |
|
|
Final Class |
1. Final class cant be subclassed to prevent method overriding |
|
|
Abstract class |
1. Can never be instantiated 2. Can only be extended 3. Contains abstract method 4. can also contain normal method |
|
|
Interface |
1. Blueprint of class. 2. Contains static constants and abstract method 3.used to support multiple inheritance 4. Methods - Public, abstract 5. variables - Public, static, final |
|
|
Class member declaration |
1. Public, protected, private ,default |
|
|
Public |
Same as class declaration |
|
|
Private |
1. Can only be accessed by the class itself 2. Cannot inherit private method |
|
|
Protected and Default |
Default member can only be accessed within package and not by importing. Private can be accessed within package and even by inheriting the class / importing package |
|
|
Constructor |
1. Special type of method used to initialize the object 2. No return type and same name as that of class name 3. Can have multiple constructors with different params |
|
|
Static |
1. Used to create variables and methods that will exist independently of any instances created for the class and there will be only a single copy of static member regardless of instance of the class |
|
|
Things you mark as static |
1. Method 2. Variables 3. Nested class 4. Initialization block |
|
|
Things you cant mark as static |
1. Constructors 2.Classes 3. Interfaces 4. method local inner classes 5. inner class methods and variables 6. local variables |
|
|
Enum in java |
1. Data type that contains fixed set of constants 2. enum improves type safety 3. enum can be easily used in switch 4. enum can be traversed 5. enum can have fields, constructors and methods 6. enum may implement many interfaces but cannot extend any class because it internally extends Enum class |
|
|
Enum Example |
class EnumExample1{ public enum Season { WINTER, SPRING, SUMMER, FALL } public static void main(String[] args) { for (Season s : Season.values()) System.out.println(s); }} |
|
|
More about Enum |
1. The java compiler internally adds the values() method when it creates an enum. The values() method returns an array containing all the values of the enum. 2. The java compiler internally creates a static and final class that extends the Enum class 3. The enum can be defined within or outside the class because it is similar to a class 4. The enum constants have initial value that starts from 0, 1, 2, 3 and so on. But we can initialize the specific value to the enum constants by defining fields and constructors. 5.Enum contains private constructor 6. Enum can have abstract methods and can provide implementation to them |
|