Professional Documents
Culture Documents
Encapsulation
• Encapsulation in Java is a mechanism of wrapping the data
(variables) and code acting on the data (methods) together as a
single unit.
• In encapsulation, the variables of a class will be hidden from other
classes, and can be accessed only through the methods of their
current class.
• Therefore, it is also known as data hiding
class Faculty {
float salary=30000;
}
class Science extends Faculty {
float bonous=2000;
public static void main(String args[]) {
Science obj=new Science();
System.out.println("Salary is:"+obj.salary);
System.out.println("Bonous is:"+obj.bonous);
}
}
Multilevel inheritances
• In Multilevel inheritances there exists single base class,
single derived class and multiple intermediate base
classes.
a) Single inheritance
b) Double inheritance
c) Hierarchical inheritance
d) Multiple inheritance
Which Method is use to implement multiple inheritance in
Java
a) Interfaces
b) Multithreading
c) Protected methods
d) Private methods