explain oops concepts with examples?
Answer Posted / dara
There are three types of oops in java.
1.Encapsulation:Encapsulation is mechanism,that binds
together data and code its manipulates.
Ex:suppose we are writing one bean.we declaring two private
variables.we are providing setters and getters methods of
two variables.These variables are accessed in that class.
2.Inheritance:To acquire the base class properties into
derived class.
Ex:class A{
m1(){
System.out.println("m1 method");
}
}
class B extends A{
m2(){
System.out.println("m2 method");
}
public static void main(String args[]){
B b = new B();
System.out.println(b.m1);
System.out.println(b.m2);
}
}
O/p is:m1 method
m2 method.
Polymorphism:one Interface to be used for a general class of
actions.
There are two types of polymorphisms.
1.Compile-time polymorphism:what object will be assigned to
the present variable.This will be evaluated at compile time.
This is known as compile-time polymorphism.
2.Run-time polymorphism:what object will be assigned to the
present variable.This will be evaluated at runtime depending
on condition.This is known as Run-time polymorphism.
| Is This Answer Correct ? | 363 Yes | 101 No |
Post New Answer View All Answers
What is a protected class in java?
What is the symbol for line break?
who can i handle multiple client in RMI
List some oops concepts in java?
What is the exact difference in between Unicast and Multicast object?
Can we modify the throws clause of the superclass method while overriding it in the subclass?
What is namespace in java?
What is the significance of listiterator?
Difference between class#getinstance() and new operator ?
How do you check if a string is lexicographically in java?
How do you decide when to use arraylist and linkedlist?
Is object a data type in java?
How do you calculate square roots?
Does garbage collection occur in permanent generation space in jvm?
enlist some features of jdk.