Inheritence 1 Answer(s) 4 years and 7 months ago
Posted in : Java Beginners
View Answers
November 7, 2008 at 1:03 PM
Hi friend,
There are two forms of inheritance in the Java language. The standard form of inheritance is by extension; a class declares that it extends another class, or an interface extends another interface. In this case, the sub-class or sub-interface inherits all the fields and methods of its parent.
The second special form of inheritance is where classes declare that they implement an interface, which has more limited consequences. When a class implements an interface, it inherits any fields from the parent as final constants, but must provide its own implementation of the interface methods.
Example:
import java.io.*;
class ClassA{
int x; int y; int get(int p, int q){ x=p; y=q; return(0); } void Show(){ System.out.println("Value of x:" + x); System.out.println("Value of y:" + y); } }
class ClassB extends ClassA{
public static void main(String args[]) throws IOException{ BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Please enter number of x!"); int x= Integer.parseInt(buff.readLine()); System.out.println("Please enter number of y!"); int y= Integer.parseInt(buff.readLine());
inheritence Vs inheritence inheritence Vs inheritence what are difference b/w c++ inheritence and java inheritence
Hi Friend,
C++ supports Multiple Inheritance while Java does not.
Thanks
inheritence in java? inheritence in java? what is inheritence and how it work inn java
Java inheritence
Java inheritence if there are 20 methods in a class if only 2 methods are used for inheritence is it better idea to use inheritence or use other logic
java inheritence
sec... so now create a base class n 4 sub class using inheritence.... like for eg
java multiple inheritence - Java Interview Questions
java multiple inheritence what are the drawbacks of multiple inheritence due to which it is not used in JAVA?Thanks in Advance. Hi friend,
drawbacks of multiple inheritence due to which it is not used in JAVA
java
java why java is platform independence?
why it does not support multiple inheritence
Deligation - Java Interview Questions
Deligation Respected sir/mam
kindly inform me how we can implement deligation in java and what is difference between deligation and inheritence
thanks
How we learn java
How we learn java what is class in java?
what is object in java?
what is interface in java and use?
what is inheritence and its type
How we learn java
How we learn java what is class in java?
what is object in java?
what is interface in java and use?
what is inheritence and its type
How we learn java
How we learn java what is class in java?
what is object in java?
what is interface in java and use?
what is inheritence and its type
How we learn java
How we learn java what is class in java?
what is object in java?
what is interface in java and use?
what is inheritence and its type
How we learn java
How we learn java what is class in java?
what is object in java?
what is interface in java and use?
what is inheritence and its type
inhertence
inhertence how many types of inheritence in java according to sun specification?
Hi Friend,
Java supports following inheritance types:
Single - level inheritance
Multi - level inheritance
Hierarchical inheritance
multiple inheritance
multiple inheritance Class A extends Class B but Class A also inherit Super Class Object so it is multiple inheritence give reason in support of your answer
Interface in JAVA - Java Interview Questions
Interface in JAVA How interface fulfills all th facilities which is provided by the Mutiple inheritence? Hi Sanjay,
Developers found the flaw available in the Java that it does not support Multiple Inheritance