Skip to main content

Posts

Showing posts from October, 2016

Why an outer Java class can’t be static

In a previous blog , I talked about why we can not define an outer class using private or protected keywords. If you have not read it, please go ahead and give it a look. I this article I will talk what is the use of the static keyword, why an outer Java class can’t be static, why it is not allowed in Java to define a static outer class. In order to understand that first, we need to understand what is the static keyword used for, what purpose it solves and how does it works. What does static keyword do Every Java programmer knows that if we need to define some behavior (method) or state (field) which will be common to all objects we define it as static. Because static content (behavior or state) does not belong to any particular instance or object, it will common to all objects and all objects are free to change any static field and every change will be visible to every object. We do not need to create any object of the class to access a static field or method, we can directly refer a

Why an outer Java class can’t be private or protected

As soon as we try to use private or protected keyword while declaring an outer class compiler gives a compilation error saying “Illegal modifier for the class your_class_name; only public, abstract & final are permitted”. Here in this article, we are going to study why we are not allowed to use these keywords while declaring outer classes. But before understating the reason behind this we need to understand Java access specifiers and their use cases. There is total 4 access specifier in Java mentioned below in the order of their accessibility. private:  anything (field, class, method, interface etc.) defined using private keyword is only accessible inside the entity (class or package or interface) in which it is defined.  default:  only accessible inside the same package and it is also known as package-private (No modifiers needed). protected:  only accessible inside the same package plus outside the package within child classes through inheritance only.  public:  can be accessed

Everything About Object Oriented JavaScript

Complete explanation of Object Oriented JavaScript 01:50  JavaScript Objects 02:36  Objects in Objects 04:12  Constructor Functions 05:58  instanceof 06:28  Passing Objects to Functions 08:09  Prototypes 09:34  Adding Properties to Objects 10:44  List Properties in Objects 11:38  hasOwnProperty 12:42  Add Properties to Built in Objects 14:31  Private Properties 18:01  Getters / Setters 21:20  defineGetter / defineSetter 24:38  defineProperty 27:07  Constructor Function Getters / Setters 29:40  Inheritance 37:13  Intermediate Function Inheritance 39:14  Call Parent Functions 41:51  ECMAScript 6 47:31  Singleton Pattern 49:32  Factory Pattern 52:53  Decorator Pattern 54:52  Observer Pattern