# Inheritance

Khaela
Inheritance
Posted in : Java Beginners

May 4, 2009 at 5:01 PM

Hi Friend,

Please try the following code which is very simple to understand. It shows how you can relate your real life working of Inheritance within the java programming.

class Points{
private double x;
private double y;

public Points(){}

public Points(double x, double y){
this.x=x;
this.y=y;
}

public void setX(double x){
this.x=x;
}

public void setY(double y){
this.y=y;
}

public double getX(){
return x;
}

public double getY(){
return y;
}

public void showCoordinate(){
System.out.println("(X,Y)="+"("+x+","+y+")");
}
}
public class Circle extends Points{

private double r;

public Circle(){}

// Circle( x-coordinate , y-coordinate, r-radius )
public Circle(double x, double y, double r){
super(x,y);
this.r=r;
}

public void setR(double r){
this.r=r;
}

public double getR(){
return r;
}

public double area(){
return Math.PI*r*r;
}

public double perimeter(){
return 2*Math.PI*r;
}

public static void main(String args[]){
Circle c = new Circle(12,3,5);
System.out.println(c.getX());
System.out.println(c.getY());
System.out.println(c.getR());
c.setX(100);
c.setY(120);
c.setR(4);
System.out.println(c.getX());
System.out.println(c.getY());
System.out.println(c.getR());
c.showCoordinate();
System.out.println(c.area());
System.out.println(c.perimeter());
}
}

Thanks
RoseIndia Team

inheritance
inheritance  how does one implement inheritance in java
inheritance
inheritance  hi.. pleaseeeeee i need a quick help(answer) in creating aprogrm in java by using inheritance for car in such away that .... Car is parent class and both of Private and Public Car extends it then both of Bus
Inheritance,Inheritance in Java,Java Inheritance
Inheritance       To know the concept of inheritance clearly you must have the idea of class and its... this, super etc. As the name suggests, inheritance means to take something
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi, java does not support multiple inheritance
Inheritance
Inheritance       To know the concept of inheritance clearly you must have the idea of class and its... this, super etc. As the name suggests, inheritance means to take something
multiple inheritance
multiple inheritance  why java doesn't support multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
Java inheritance
Java inheritance   can the child access protected content of the parent if the child is in a different project   If you have considered different project as different package then the child cannot access the content
javascript inheritance framework
javascript inheritance framework  javascript inheritance framework
Multiple Inheritance
Multiple Inheritance  Why Java Doesn't have Multiple Inheritance It is Advantage or Disadvantage.........   Hi Friend, When we extends... and inconsistencies Java does not support Multiple Inheritance. Thanks
Multiple Inheritance
Multiple Inheritance  All are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined... class so java any how do multiple inheritance? Can you please explain
Inheritance question?
Inheritance question?  Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable and AccountsPayables. The Company performs following operations. (1
Inheritance question?
Inheritance question?  Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable and AccountsPayables. The Company performs following operations. (1
Inheritance
Inheritance       To know the concept of inheritance clearly you must have the idea of class and its... this, super etc. As the name suggests, inheritance means to take something
Inheritance in Spring
Inheritance in Spring       Inheritance Demo, In the example given below we are going to tell about the inheritance in the Spring framework. By inheritance we mean a way
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (simple and multiple) inheritance
Inheritance
other features like creation and implementation of the object, Inheritance etc...; float p, q;   public Rectangle...(){   return(p * q);
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (single and multiple) inheritance.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Thanks
inheritance - Java Beginners
inheritance  help me on inheritance concept in java specialy on overloading and overridding concept
Concept of Inheritance in Java
Concept of Inheritance in Java Concept of Inheritance in Java is considered one of the important features of Object Oriented Programming. Inheritance... class from parent class. Let's understand the concept of inheritance in Java
creating inheritance of cars
creating inheritance of cars   hi ... please help me in creating inheritance between some types of cars like car that is parent and both of private car and public car are extends it then bus and truck extends public car
Maven's order of inheritance
Maven's order of inheritance  hello, What is Maven's order of inheritance?   hii, 1.parent pom 2.project pom 3.settings 4.CLI parameters
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
Inheritance in Java 7
This tutorial describe concept of Inheritance. It is one of OOPs concept
What type of inheritance that php supports?
What type of inheritance that php supports?  What type of inheritance that php supports
What are the types of inheritance models in Hibernate?
What are the types of inheritance models in Hibernate?  Hi, What are the types of inheritance models in Hibernate? thanks
multiple inheritance - Java Beginners
multiple inheritance  Why java does not support Multiple Inheritance?  First of all the question is wrong the correct one is......... Q)why java classes does not support Multiple Inheritance? JAVA CLASSES ONLY