This site javatpoint is very useful for programming languages like JAVA,PYTHON,C,C++, Data Structures etc.Java learning Concept also provides technical materials , which are related to latest technologies. We provides very easy lectures to our viewers from beginning to advance level.We focus logical content instead of theoretical content.

Tuesday, 24 October 2017

INHERITANCE IN JAVA

INHERITANCE IN JAVA:

inheritance is a process of creating some new classes called sub/child class.and some other class called parent class.sub class inherit all the properties of  parent class.
class Sample
Super class is an elevated class that supplies it's attribute and methods to the ladder of sub classes. Sub classes are an object class that is derived from a super class from which it inherit the base set of properties and methods.  In general inheritance is the process of developing a new class from an existing class.  An existing class is called a base class or super class or parent class. The new class is called sub class or derived class or child class. Inheritance permits the subclass to use the base class properties and methods. Inheritance involves a super class and subclass the superclass is a General class and subclass is a special class.  The sub class is an extended version of the supervisor. The subclass inherits fields and methods from super class without any of them being return.
A subclass override the superclass methods.
Inheritance in Java we can use by extends keyword .java does not supported the multiple inheritance. It very simple and easy to understand. It is very important feature of Java.
Example

Student 
{
int  a=10,b=20,c;
void sum()
{
c=a+b;

}

void display()
{
System.out.println(c);
}
}
class Demo  extends Sample
{
void multi()
{
c=a*b;
}
public static void main(String ob[])
{
 Demo s1=new Demo();
s1.sum();
s1.multi();
s1.display();
}
}



Adbox