Java is object oriented programming and it’s developed by sun
Microsystems of USA in 1991. A first name of java is OAK then
GREEN and last and finally renames its name and called java. As
mentioned earlier object oriented is a term, now it is necessary to
understand some of the concepts used extensively in object oriented
1. Classes and objects
6. Dynamic binding
class are user defined data type its contains data members and
method and object are runtime entity and instance of class.
Each class is implementing in its own source file.
Name of the java file is the same as the class name.
Java application must include a class with a main method e.g.
public static void main (String args).
A class is not the same as the object that is made from it. A class is
just like the blue print of the object, and the object is just like the
product that is made by using the blueprint. For example car is a
class but its category BMW, Maruti, Ford Figo is objects.
Inheritance is the process by which one object acquires the properties of
another object. This is important because it supports the concept of
Inheritance method in java
class derived class name(B) extends base class (A)
Example: Suppose take two java classes Class A contains 2 variables and
ClassB Extends Class A that means here ClassB can access the classA
variables without declaring it. If we do this then the memory will be less
polymorphism means the ability to take more than one form
and its two type
1. Compile time polymorphism
2. Run time polymorphism
Method overloading is an example for Compile
time polymorphism and Method overriding is an example for
Run time polymorphism
Hiding unnecessary things and showing the essential
Example: Suppose take a car: In that we will have breaks and
steering and etc... Here when we are changing the gear box to
up or bottom then gears will work but we don't know how they
are managing internally and we don't no how it is working. As
a driver we don't need to know how it is working internally
when we are changing every time. That is the reason they will
hide the wires and cables internally and they will show up
only gear box to us.
Wrapping up of data and methods into a single unit known as
class and it’s the most striking feature of a class.
Firstly we compile the programs (javac hello.java).
Second we run the program (java hello).