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();
}
}









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
hibernate over Jdbc
hibernate over Jdbc  Why use hibernate over Jdbc?   Hibernate provides lots of advantages over JDBC. Some of them are as below: 1) Hibernate is data base independent 2) Hibernate provides its own query language called
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   
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
RMI over Internet - RMI
RMI over Internet  Hello I've made a project which utilizes rmi for communication. Problem: I am unable to communicate using rmi over internet 1)the clients cannot connect to me 2)I am using client side callbacks 
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
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
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
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
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
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 question
method question  How do I figure out the difference in a method heading, a method body, and a method definition
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 Overloading
Method Overloading  In java can method be overloaded in different class
Method Overloading
Method Overloading  In java can method be overloaded in different class
A method getColumnCount.
A method getColumnCount.  There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set
abstract method
abstract method  is final method is in abstract class
ModuleNotFoundError: No module named 'cluster-over-sampling'
ModuleNotFoundError: No module named 'cluster-over-sampling'  Hi...: No module named 'cluster-over-sampling' How to remove the ModuleNotFoundError: No module named 'cluster-over-sampling' error? Thanks   Hi
ModuleNotFoundError: No module named 'dns_over_https'
ModuleNotFoundError: No module named 'dns_over_https'  Hi, My... named 'dns_over_https' How to remove the ModuleNotFoundError: No module named 'dns_over_https' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'source-over-ssh'
ModuleNotFoundError: No module named 'source-over-ssh'  Hi, My... named 'source-over-ssh' How to remove the ModuleNotFoundError: No module named 'source-over-ssh' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'udp-over-tls-pool'
ModuleNotFoundError: No module named 'udp-over-tls-pool'  Hi, My... named 'udp-over-tls-pool' How to remove the ModuleNotFoundError: No module named 'udp-over-tls-pool' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wdb_over_pdb'
ModuleNotFoundError: No module named 'wdb_over_pdb'  Hi, My Python... 'wdb_over_pdb' How to remove the ModuleNotFoundError: No module named 'wdb_over_pdb' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cluster-over-sampling'
ModuleNotFoundError: No module named 'cluster-over-sampling'  Hi...: No module named 'cluster-over-sampling' How to remove the ModuleNotFoundError: No module named 'cluster-over-sampling' error? Thanks   Hi
ModuleNotFoundError: No module named 'dns_over_https'
ModuleNotFoundError: No module named 'dns_over_https'  Hi, My... named 'dns_over_https' How to remove the ModuleNotFoundError: No module named 'dns_over_https' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jupyter-http-over-ws'
ModuleNotFoundError: No module named 'jupyter-http-over-ws'  Hi...: No module named 'jupyter-http-over-ws' How to remove the ModuleNotFoundError: No module named 'jupyter-http-over-ws' error? Thanks   Hi
Static method
Static method  what is a static method?   Have a look at the following link: Java Static Method
gc() method
gc() method  what is difference between java.lang.System class gc() method and java.lang.Runtime class gc() method
method name
method name  Is there any method which is equivalent to c++'s delay(int) function
What is benefits of Apache Kafka over the traditional messaging
What is benefits of Apache Kafka over the traditional messaging  Hi, What is benefits of Apache Kafka over the traditional messaging? How you will compare Apache Kafka with JMS based messaging? Thanks
Compression of rolled-over files using log4j
Compression of rolled-over files using log4j  How can I use log4j to rollover the log files on hourly basis and compress the rolled over files
What is benefits of Apache Kafka over the traditional messaging
What is benefits of Apache Kafka over the traditional messaging  Hi, What is benefits of Apache Kafka over the traditional messaging? How you will compare Apache Kafka with JMS based messaging? Thanks

Ads