method over riding

method over riding

write a java program to compute volume of sphere and volume of cylinder using method over riding

View Answers

June 30, 2011 at 12:04 PM

class Sphere {
double volOFSphere;
Sphere(double r){
volOFSphere =(4*3.14*r*r*r)/3;
}
void volume() {
System.out.println("Volume of Sphere: " + volOFSphere);
}
}
class Cylinder extends Sphere {
double volOfCylinder;
Cylinder(double r,double h) {
super(r);
volOfCylinder = 3.14*r*r*h;
}
void volume(){
super.volume();
System.out.println("Volume of Cylinder: " + volOfCylinder);
}
}
class MethodOverriding{
public static void main(String args[]) {
Cylinder c = new Cylinder(10, 20);
c.volume();
}
}

Ads









Related Tutorials/Questions & Answers:
method over riding
method over riding  write a java program to compute volume of sphere and volume of cylinder using method over riding
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
Advertisements
method
method  can you tell me how to write an abstract method called ucapan() for B2 class class A2{ void hello(){ system.out.println("hello from A2"); }} class B2 extends A2{ void hello(){ system.out.println("hello from B2
Transmitting messages over net
Transmitting messages over net  A method whereby messages to be transmitted between computers are all sent to a central computer, which gathers them and routes them to the appropriate destinations is known as - 1. Message
mouse over effects in css
mouse over effects in css  I have written a mouse over effect in CSS. But it is not working in HTML. Can any one suggest me? Thanks
Call UIViewController over RootViewController
Call UIViewController over RootViewController   Hi, i have created the window based application.. but not sure how to call the UIView over RootViewController. Thanks
Data over Voice Communication
Data over Voice Communication  I just Want to know that Data Over Voice communication is possible in India or Not, If not then Why. and If Yes then Why Please anyone give the answer
Method overriding
Method overriding  can a method declared in one package be over ridden in a different package?   A subclass in a different package can only override the non-final methods declared public or protected
application over https
application over https   Hi. This questions might be very simple but I would like to create a simple servlet program and want to access using https... while accessing https over http
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
JavaScript fontColor method
the method fontColor() over any string instead of using the <font></font> tags. The fontcolor() method in JavaScript can be used to color strings... JavaScript fontColor method   
why should we over ride hashCode(), when equals was over ride()?
why should we over ride hashCode(), when equals was over ride()?  why should we over ride hashCode(), when equals was over ride
Is AI taking over the world?
Is AI taking over the world?  Hi, I am beginner in Data Science... taking over the world? Try to provide me good examples or tutorials links so that I can learn the topic "Is AI taking over the world?". Also tell me
What is the advantage of hibernate over JDBC?
What is the advantage of hibernate over JDBC?  HI, What is the advantage of hibernate over JDBC? thanks
What is the advantage of hibernate over JDBC?
What is the advantage of hibernate over JDBC?  HI, What is the advantage of hibernate over JDBC? thanks
Image writing over URLConnection
Image writing over URLConnection  Hello, I am trying to write an image over an HttpURLConnection. I know how to write text but I am having real problems trying to write an image I have succeeded in writing to the local HD using
ModuleNotFoundError: No module named 'over-stats'
ModuleNotFoundError: No module named 'over-stats'  Hi, My Python... 'over-stats' How to remove the ModuleNotFoundError: No module named 'over... have to install padas library. You can install over-stats python
method inside the method??
method inside the method??  can't we declare a method inside a method in java?? for eg: public class One { public static void main(String[] args) { One obj=new One(); One.add(); private static void add
Will AI take over data science?
Will AI take over data science?  Hi, I am beginner in Data Science... take over data science? Try to provide me good examples or tutorials links so that I can learn the topic "Will AI take over data science?". Also
Will AI take over data analytics?
Will AI take over data analytics?  Hi, I am beginner in Data Science...: Will AI take over data analytics? Try to provide me good examples or tutorials links so that I can learn the topic "Will AI take over data analytics?"
Can AI take over humans?
Can AI take over humans?  Hi, I am beginner in Data Science... over humans? Try to provide me good examples or tutorials links so that I can learn the topic "Can AI take over humans?". Also tell me which
get method
get method   how to use get method: secure method is post method and most of use post method why use a get method
How to iterate over a checkbox group
How to iterate over a checkbox group  Hi. I am new to using JQuery and would much appreciate your help. I have a form on which I've created 5..." groups. My plan of attack was to iterate over the MASTER checkbox group
method question
method question  How do I figure out the difference in a method heading, a method body, and a method definition
Method
Method       In this section, we will explore the concept of method in the reference of object oriented... and behaviors are defined by methods. Method : An brief introduction Methods
Method Overloading
Method Overloading  In java can method be overloaded in different class

Ads