Monday 28 April 2014

Object Oriented Programming

The four feature of the object oriented programming

1) Inheritance
2) Abstraction
2) Encapsulation
4) Polymorphisam

1) Inheritance

we can use the property and behaviour from the main class to sub class using "extends" keyword.

Ex: if we want to write same moving behaviour as per the old car for new Ferrari car , we can extends the same behaviour from old car. So we can concentrate only writing code for the new behaviour. And we can inherite the pre writen functionality for make reuse of it. This is the use of Inheritance.

2) Abstraction:

-> Hiding the complexity
-> Composition
-> Aggregation

we can divide and segrigate the perticular related properties and behaviour into separate class. And we can reuse of it by creating the object for the perticluar class.

Ex: if we consider the Address class, its have proeprties of first line, second line, Street name, picode. We can create the seperate class and make reuse of another class.


3) Encapsulation:

-> Hiding

-> using Access Modifiers (Public, Default, Protected, Private)

THis mehod used for protect some Properties and behaviour of the some perticular object.

If we want Properties and behaviour of the some perticular object is should not used by other other object, that time we can use the Encapsulation for protecting the data.



4) Palymorphism

-> Overloading
-> Overriding

we can call the same function name in different place.





How java Platform independent language?


File.java -> JAVA COMPILER -> File.class -> JAVA VIRTUAL MACHINE -> Execution

1) .java flie convertied into .class file by using Java compiler. This .class file make readable and used by many operating system. .java is not readable for any operating system.

2) .class file converted into execution by using Java virutla machine.

3) Here Java virtual machine is not platform independent. Each and every operating system have the seperate Java virtual machine. But all java virtual machine can read and .class file and convert into appropriate operating systems.

No comments:

Post a Comment