Although I want to write full article for a topic in JAVA but today I
felt, some times small tips are more important than a full page theory
when you want to revise quickly like for an interview ;)
I’m writing here few notes which I have collected while reading Java Books and hope these would be helpful for you too.
Final Classes:
C YA BUDDY!!!
I’m writing here few notes which I have collected while reading Java Books and hope these would be helpful for you too.
Final Classes:
- String Class can’t be sub classed.
- Final class obliterates a key benefit of OOP – Extensibility.
- Final class uses for safety and security.
- In abstract class, method marked abstract end in a semicolon(;) rather than curly braces.
- If you change a method from abstract to non-abstract then you need to change the semicolon at the end of the method declaration into a curly braces pair.
- All the interface method must be implemented and must be public and abstract(implicitly it is already done).
- An interface is an 100% abstract class.
- But an abstract class can have abstract or non-abstract methods, while an interface can have only abstract methods (this is the difference).
- All variable defined in an interface must be public , static and final it means interface can declare only constants, not instance variables.
- Interface methods must not be static as interfaces defines instance methods.
- You can’t change the value of constant or variable defined in interface from implementing class, it will give compiler error.
- Boolean equals(object obj)
- void finalize()
- int hashcode()
- final void notify()
- final void notifyall()
- final void wait()
- String toString()
- This method simply spit out object state(or in other words) get the current values of the important instance variable.
- When you pass an object reference to System.out.println() method it will call object.toString() method implicitly.
C YA BUDDY!!!