You are on page 1of 2

Java:

+++++
What is a class?
Class defines the behaviour of an object.
Class can have Data members, methods.
EX:
class <className> //CamelCase
{
//Data Members
//Functions or Methods
}
class sample
{
int a;
int b;
void add(int a, int b)
{
//Method definition
}
}
What is an Object?
Object is an real time entity.
Object is an instance of a class.
What is OOP? // object Oriented Language
Any language which follows the below will be called as OOP.
1) Inheritance
2) Polymorphism
3) Encapsulation
4) Abstraction
Inheritance:
-----------The properties of one class is aquired by another class, is called Inheritance.
Ex:
Vehicle
Car, Bus, Bike
Polymorphism:
------------+ => 2+4 = 6
//add
+ => abc+cde = abccde //concatenate
operator overloading //+ only java can support
Method overloading
Method overriding
Overloading:
-----------void method(int a, int b)
void method(int a)
void method(String str)

int method()
overriding:
----------void method(String args)
{
System.out.println("Hi, Hello.."+args);
}
void method(String agrgs)
{
System.out.println(args);
}

You might also like