ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Describe inheritance as applied to java?
 Question Submitted By :: Sai
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Describe inheritance as applied to java?
Answer
# 1
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 ?    1 Yes 0 No
Rajesh
 
  Re: Describe inheritance as applied to java?
Answer
# 2
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 ?    1 Yes 0 No
Chandra Rekha
 
 
 
  Re: Describe inheritance as applied to java?
Answer
# 3
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 ?    1 Yes 0 No
Shivaprasad
 
  Re: Describe inheritance as applied to java?
Answer
# 4
inheritance is the process of inheriting the properties of 
super class to sub class
 
Is This Answer Correct ?    1 Yes 0 No
Ravikiran
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
How multi processing is achieved in JAVA? BMC2
how to print output with out using sop statements UHG2
How to declare unique ArrayList ? RMSI3
what is Vector class?  2
What is thin driver and thick driver. why it is called so? Logisoft1
Which class has no duplicate elements?  6
Which method will get invoked first in a stand alone application?  1
Can a for statement loop indefinitely?  3
Can an anonymous class be declared as implementing an interface and extending a class?  1
Under what circumstances an object reference be cast to an interface reference?  2
How can a class be accessed, If no access modifiers are declared?  2
What is a compilation unit?  1
Different types of Layouts?  3
What is the use join() in Threads ? HCL3
1).what is the difference between below examples String s="vijay"; String s=new String("vijay"); TCS10
where do we use init()  1
Difference between String and StringBuffer. IBM3
What are different types of Exceptions?.  2
What is the difference between this() and super()? TCS5
What is a Wrapper class?  3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com