Skip to main content

Posts

Showing posts from February, 2018

OOP Encapsulation with Modifiers..

                  In this blog we can know about why we go for JAVA?. Java is a language known for object oriented features and its network support. Here object oriented is achieved by three concepts Encapsulation Inheritance Polymorphism                 but Java is not pure object oriented  because of its support to primitive data types(explained later..) like int, float,...to overcome this JAVA has loaded with wrapper class( know more ).          Encapsulation,   we had come across the word "capsule" many times in our life. capsule is nothing but a outer protection(cover) used to protect the something from external factors. example the medicines usually come with a capsule to protect the chemicals inside it. Similarly the encapsulation is used to wrap the code or data from intruders in order to ensure its security. It can be achieved from modifiers. Java has many modifiers each with unique characteristic features but for encapsulation we commonly g

Object in Java..

         Object is a thing used to access a member in class. (i.e) the class members which are non static can be accessed in other class using object it is also referred as Instance of a Class. It is created during run time so its a run-time entity. Object can be used access only one class. But class can have multiple objects unless the constructor is declared as static. For static constructor only one object can be created. During run time object gets created and only when object created the memory of the class variables gets created and the object's memory gets stored in heap. Object can't be created for abstract class and interfaces.   Any object should posses  Identity State Behavior  To create a object Declare a reference variable Construct object with "new" keyword. new is used for dynamic memory allocation.  Assign the reference variable to new keyword. and construct the object. Example: class A{ int a,b; static int x,y; A(){ } void