JAVA is an Object-Oriented, Internet Programming language.
It's main feature are :-
- Platform Independent.
- Security.
Orientation :- Means thinking/prospective
Orientation is a way of thinking in terms of Object. On the basis of
this thinking a programming model is created by the name object oriented
programming structure this programming model simplifying software
development & maintenance with the following concept.
OOp's Basic Concepts :-
- Object
- Classification
- Generalization & Inheritance.
- Polymorphisum
- Data Encapsulation.
Object:- Object is a discrete entity which has well
define attribute & behaviours it can be a physical things as
well as an abstract concept.
Classification :- Classification
is a process of grouping object having common attribute &
behaviours into logical unit called class. Concept of classification
simplify object management.
Generalization :- Generalization
is a process of abstraction in generalization common feature of classes
are abstracted so that they can be easily managed so that they can be
easily managed so that they can be easily managed. Concept of
generalization simplify management of classes.
Inheritance is the mean of implementing generalization.
Polymorphism :- Polymorphism in the class concept of programming
concept of polymorphism state that the behaviours can be manifest in
different ways. There are two way aspect of polymorphism.
- One Object manifest the behaviour in different ways.
- Different object manifest the same behaviour in different ways.
Behaviour is implemented
as method which need to be name. A method can be name on the basis of
behaviour or on the basis of manifest can be multiple. hence
identification is simplified by meaning the method on the basis of
behaviour. Concept of polymorphism simplify the behaviours of
management.
Encapsulation :- is
concept of Data encapsulation deal with the protection of data from
accidental or unintentional corruption by the programmer. This concept
state that scope of data must be confine within logical unit called
class's, Data of one class must not be accessed directly from another
class.
Any programming
language provide the implementation of these five concept is called
Object Oriented Programming Language.
Difference Between Method And Function : The term function represent a task where as term method represent behaviours.
Anonymous Block : (init block) - is
a block of statement which doesn’t have a name associated to its init
block are use in case of overloaded constructor to define common
statement of all constructor.
If there are more than one init block in a class then there
statement are group in the order of there occurrence in the class.
Before there move to the constructor.
Static Keyword : is use to define class member in a class there can be following class member.
- static data member.
- static block.
- static method.
- Static data member represent class attribute that is information
common to all object of the class. Only single copy of static data
member is created at the time of class loading this single copy is
shared by all object of the class.
- Static block is a block of statement which is executed on it's on
just after a class is loaded. It represents initialization of a class,
that is use to initialize static data member of a class.
static {/*statement to be executed at the time of class loading.*/}
- Static methods represent behaviour of a class they are invoke using the class name.
Final Keyword in Java : final keyword is similar to
const keyword in other language. final keyword used to restrict user, it's use in various way.
- Variable
- Method
- Class
- Final Variable used to declared constant value which once assigned, it's value can't be changed further.
- A final method can't be overridden by super class. This technology
prevent unexpected behaviour of class.
Note: private and static methods are always implicitly final in Java, since they cannot be overridden.
- final class can't be overridden by any class, implicitly all method of final class are declared as final. but not data member. final method are inherited? (yes, but can't be overridden it.)
This
Keyword In Java :
this keyword
used to refer current object.
this is always
a reference to the object on which method was invoked.
this can be
used to invoke current class constructor.
this can be passed as an argument to
another method.
Example:
public class Box {
Double width, height, dept;
public Box(double w, double h, double d ) {
this.width = w;
this.height = h;
this.dept = d;
}
}
Here the this is used to initialize member of current object.
The this is used to call overloaded constructor in Java.
public class Car {
private String name;
public Car() {
this("BMW"); // overloaded
constructor is called.
}
public Car(String n) {
this.name = n; // member is initialized
using this.
}
}
The this is also used to call Method of that class.
public void getName() {
System.out.println("TechA2ZSolution");
}
public void display() {
this.getName();
System.out.println();
}
this is used to return current Object
public Car getCar() {
return this;
}