top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is inheritance?

+1 vote
420 views
What is inheritance?
posted Sep 18, 2014 by Varnita Chaudhari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

inheritance means to acquire properties of some other. Here in case of java inheritance denotes one class acquiring properties from other method called parent class. We denote it by using extends key word and in some case implements key words.

If we say
public class test2 extends test1 {....}

It means test1 have some properties which are inherited to test2, not all of them.

answer Sep 18, 2014 by Debayan Kabiraj
+1 vote

Inheritance means importing the characteristics from another object. Or we can say that by this way an object can pass its state and behaviors to its children.

Java allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of MountainBike.

class MountainBike extends Bicycle {
    // new fields and methods defining 
    // a mountain bike would go here
}

In the above example MountainBike is inhariting the Bicycle which gives MountainBike all fields and methods as Bicycle.

answer Sep 23, 2014 by Salil Agrawal
...