- Ability to identify a function to run.
- One name many forms.(some object/function behaving as many forms)
- Also called method and operator overloading.
- Method with same name,but different signature,signature means:
- No. of parameters
- Type of parameters
- Order of parameters
2)Run-time(Overriding)
- Method of base class is re-defined in the derived class.
- Method with same name,same signature and exactly the same return type.
INHERITANCE
- Child class allows to inherit properties from its parent class(extends keyword).
- Access only public/protected.
Multiple inheritance
- Child class inherit properties from multiple classes.
- Java does not allow extend multiple classes.
- Problem with multiple inheritance:
If multiple parents have methods with same name,then at run at run time difficult to decide for the compiler,which method to execute.
- Converting real world objects in term of class.
- Concept of defining an idea in term of classes or interfaces.
ex:-
public class Vehicle{
public string model;
}
ENCAPSULATION
ENCAPSULATION
- Considered as Hiding data
- Combining methods & attributes into a class
- Users access private attributes via public methods
ex:-
public class Person{
private string name;
public void setName(){
this.name= "Lahiru";
}
public string getName(){
return name;
}
public void setName(){
this.name= "Lahiru";
}
public string getName(){
return name;
}
}
Very helpful..short and easy to understand! Thank you.
ReplyDelete