Monday, February 27, 2012

Reflection in Java

Collection in Java

Collections in Java

Java OOPS Concept ....Encapsulation

Encapsulation to encapsulate or hide the data
for e.g Declare class variables as final; its data will be accessed by public methods.
by default default access modifier -->in packages
protected-->in package and subclasses
private-->in same class
public--->global

Java OOPS Concept .... Inheritance

Inheritance...inheriting from parent class.
Re usability....

Java OOPS Concept ....Abstraction

Abstraction means hiding the complexities.
Abstract class or interface...
We cannot instantiate this classes.
We need to extend them
We are only concerned about calling the methods for using the functionality.
for e.g stop and start method to stop and start a car...how is it implemented we are not bothered.
Its Closely associated with Encapsulation.

Assigning Child object to parent

We can assign Child object to Parent but not vice-a-versa
class Employee;
class Developer extends Employee
class Tester extends Employee
Employee e= new Employee();
Employee e = new Developer ();--->Developer is a employee
Developer d= new Employee();---->What if Employee is a tester

Java OOPS ...PolyMorphism

1)Static Polymorphism
Method overloading
methods overloaded in class with same name, but different datatype and no of argument
int test(int a, intb);
double test(double y);
2)Dynamic Polymorphism
Method overriding
Overriding the method of parent class.
class A{
int method (int x){}

}
class B extends A{
int method (int x){}
}
All the interfaces are example of method overriding