explain the concept of inheritance with an example?

Answer Posted / kkr

Inheritance is the process of creating the classes from existing classes by using 'extends' key word.
It is like IS-A relationship between the classes.

eg : Parent and child relationship. we cal parent class as super class and child class will be subclass.i.e the subclass will have all the members of super class.

Adv : Reusability of the code.i.e productivity will be increase. 

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you calculate the depth of a binary tree if the tree contains 15 nodes?

830


What is %d in printf?

750


What is the function of static in java?

766


What is a flag value?

715


What is a java developer salary?

736


Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)

1080


Explain about java sdk?

806


How is a structure different from array ?

789


What is the primitive type short?

795


What does java se mean?

773


Can java object be locked down for exclusive use by a given thread?

776


What is substring 1 in java?

780


What is Java Annotations?

741


Why vector is used in java?

767


Does java support function overloading, pointers, structures, unions or linked lists?

824