Describe inheritance as applied to java?

Answers were Sorted based on User's Feedback



Describe inheritance as applied to java?..

Answer / chandra rekha

Inheritance is one of the OOPS concepts(the OOPS concepts
are Abstraction,Encapsulation,Polymorphism and Inheritance).
Java is purely a OOP language.

Inheritance is the ability of a class to use member data
and methods of another class.This is done by deriving a
class from a diff class.The class from which it derives is
called the base or the parent or super class and the class
which derives is called the derived or the child or sub
class.

Java supports two types of inheritance SINGLE inheritance
and MULTILEVEL inheritance."extends" is the keyword to
inherit properties of the base class.All the derived
classes having a single base class is termed as the single
inheritance.for example
class A
{
...
}
class B extends A
{
...
}
public class C extends A
{
...
}
this is single inheritance

whereas, a class inherits the properties of another class,
for example
class A
{
...
}
class B extends A
{
...
}
public class C extends B
{
...
}

java doesnot support multiple inheritance.However, a class
can implement any number of interfaces(interface is a
collections of methods with no definition(abstract methods))

Is This Answer Correct ?    13 Yes 4 No

Describe inheritance as applied to java?..

Answer / rajesh

Inheritance is the powerful mechanisam for resuabiltiy.
We can derive a class from whereever and whenever.
The resuabiltiy avoids to rewrite code and code length.

Is This Answer Correct ?    8 Yes 2 No

Describe inheritance as applied to java?..

Answer / ravikiran

inheritance is the process of inheriting the properties of
super class to sub class

Is This Answer Correct ?    5 Yes 0 No

Describe inheritance as applied to java?..

Answer / shivaprasad

Inheritance is a form of software re usability in which new
classes are created from existing classes by absorbing their
attributes and behavior using the key word 'extends'.
The class which absorbs the properties is called 'sub class'
and the class which is used is called 'super class'.
Ex:
class Room
{
void roomAttributes()
{
int roomlength;
int roomheight;
int roombreadth;
String roomname;
}
void roomBehavior()
{
System.out.println("Two windows");
System.out.println("One 6.2*3.5 door");
}
}
public class BedRoom
{
public static void main(String[] args)
{
Room roomobj=new Room();
roomAttributes();
roomBehavior();
int area= room.length*room.breadth*room.height;
}
}
In the above example the room is a super class from which
bedroom(subclass) is inheriting the properties and
attributes. This is simple inheritence.
Similarly, multi level inheritence is also possible.

Ex: class A extends B
class B extends C
class C extends D

But, java does not support multiple inheritance.
Ex: class A extends B, c

For better reference : Deitei & Deitel or Balaguruswamy

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is a string what operation can be performed out with the help of a string?

0 Answers  


Hai friends I am MCA 2006 passout. Spend time in 1 yr for teacing and 5 months in small s/w firm. worked in 4 or 5 months in few places. Presently I am writing bank exams. I want to get back to IT sector. Are there any possibilities. any growth prospects?. I am having some knowledge in core and advanced java. I am so desperate. Any suggestions thanks in advance. u can write to my mail mahidestiny@gmail.com

4 Answers  


What is sortedset in java?

0 Answers  


Can try statements be nested?

3 Answers   Wipro,


How infinite loop is declared?

0 Answers  






List out five keywords related to exception handling ?

0 Answers  


Relationship between an event-listener interface and an event-adapter class?

1 Answers  


In a container there are 5 components. I want to display the all the components names, how will you do that one?

0 Answers  


waht You know about thread programming?

1 Answers  


How do you get the length of a string in java?

0 Answers  


What is blank final variable?

0 Answers  


How can you read an integer value from the keyword when the application is runtime in java? example?

0 Answers   HCL,


Categories