Share on Google+Share on Google+

Suresh Shahapurkar
javaprogram 26
1 Answer(s)      5 years and 7 months ago
Posted in : Java Beginners

Write a java progtram to create two classes commercial and domestic. override the metod calculatebill() of commercial class(Rs.8 per unit)into domestic class(Rs 6 per unit) to comput electricity bill for both classes.

Ads

View Answers

August 23, 2011 at 1:34 PM


class Commercial {
int i=0;
Commercial(int a) {
i = a;
}
void calculateBill() {
int units=100;
int cost=100*i;
System.out.println("Commercial Bill is of Rs "+cost);
}
}

class Domestic extends Commercial {
int k=0;
Domestic(int a, int b) {
super(a);
k = b;
}
void calculateBill() {
int units=100;
int cost=100*k;
super.calculateBill();
System.out.println("Domestic Bill is of Rs "+cost);
}
}

class Bill {
public static void main(String args[]) {
Domestic bill = new Domestic(8, 6);
bill.calculateBill(); 
}
}









Related Tutorials/Questions & Answers:
javaprogram 26
javaprogram 26  Write a java progtram to create two classes commercial and domestic. override the metod calculatebill() of commercial class(Rs.8 per unit)into domestic class(Rs 6 per unit) to comput electricity bill for both
javaprogram 14
javaprogram 14  Write a java program to calculate the percentage of a student marks by using java airthmatic operators like +(addition),%(division).   import java.util.*; public class Student { public static void
Advertisements
This is 26 set of different shades of Black covers light brown to darker Black.
:5px 0px 5px 5px; } This is 26 set of different shades of Black covers... #140C0C Black 25 #0B0707 Black 26 #1C1313
This is the 26 color set of Blue ranging from light to darker.
:5px 0px 5px 5px; } This is the 26 color set of Blue ranging from light... #0F4D92 Blue 26 #417DC1
This is the 26 color set of Green ranging from light to darker.
:5px 0px 5px 5px; } This is the 26 color set of Green ranging from light... Green 25 #014421 Green 26 #008000
Here is a set of 26 different shades of one of the most favourite Red colors
:5px 0px 5px 5px; } Here is a set of 26 different shades of one of the most... #380000 Red 25 #300000 Red 26 #280000
This is a versatile shade of blue named Violet. Here is the a set of Violet of 26 different shades.
is the a set of Violet of 26 different shades. Name/String Code... #CFA5E6 Violet 26 #B2BEB9
This is a versatile shade of blue named Yellow. Here is the a set of Yellow of 26 different shades.
is the a set of Yellow of 26 different shades. Name/String Code... #EEE600 Yellow 26 #F3E5AB
This is a set of 26 different shades of brown colors covering light brown to darker brown.
:5px 0px 5px 5px; } This is a set of 26 different shades of brown colors... Brown 24 #F5DEB3 Brown 25 #321414 Brown 26
Here is a set of 26 different shades of one of the most favourite Pink colors rangeing from light Pink color to darker Pink color.
:5px 0px 5px 5px; } Here is a set of 26 different shades of one of the most... Pink 26 #DE6FA1
Here is a set of 26 different shades of one of the most favourite Orange colors rangeing from light Orange color to darker Orange color.
:5px 0px 5px 5px; } Here is a set of 26 different shades of one of the most... #CD5700 Orange 25 #FF6347 Orange 26 #E34234
Features of Servlet 2.5
Features of Servlet 2.5       This version has been released on September 26, 2005 by the Sun MicroSystems. It is not necessary that all web servers and application servers support
Windows 8, the New Operating System from Microsoft
is finally over with its official launch on October 26. Windows 8 unlike all previous
\wrapper
to binary and hexadecimal expected output: String s = 26 Integer m = 26 String s = 26 String x = 6 integer m = 26 Integer.MIN_VALUE = -2147483648
\wrapper
to binary and hexadecimal expected output: String s = 26 Integer m = 26 String s = 26 String x = 6 integer m = 26 Integer.MIN_VALUE = -2147483648
\wrapper
to binary and hexadecimal expected output: String s = 26 Integer m = 26 String s = 26 String x = 6 integer m = 26 Integer.MIN_VALUE = -2147483648
Can anybody help me with this simple MySql code
2013-03-17 17:25:15 2 34 23 ind 2013-03-16 18:26:20 3 34 37 ken 2013-03-17 18:26:32 1 54 61 jpy 2013-03-17 18:26:40 5 23 33 aus 2013-03-17 18:26:42 6 32 35
How to calculate sum of HH:MM:SS Format?
How to calculate sum of HH:MM:SS Format?  how to calculate sum of HH:MM:SS? for example: 10:25:36+26:50:56 calculate sum of these values
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
Tomcat - WebSevices
Tomcat Error calling delegate restart  I am getting error like! ENTRY org.eclipse.wst.server.core 4 0 2008-03-10 12:26:33.992 !MESSAGE Error calling delegate restart() Tomcat v5.0 Server at localhost
How to insert new line after every space in java
How to insert new line after every space in java  Hii Sir, I have a string with values 69 17 17 16 2 1 1 26 26 56 like this .Now as per my need i have to put all these values into new lines on getting space
Java basics
be similar to class name. (ex. If class name is JavaProgram than file name should
logic for c language
logic for c language  01 02 03 04 05 06 20 21 22 23 24 07 19 32 33 34 25 08 18 31 36 35 26 09 17 30 29 28 27 10 16 15 14 13 12 11
java
java  write a java code given string="bob" as alphabets are 26 Assign A or a as 1,B or b as 2,........Z or z as 26 now "bob" means 2+15+2=19 as b=2,o=15 Now how can i assign values for any given string and get calculated to get
Displaying Hierarchical data in JTree
;JavaProgram", "JavaNews",  "Java","project"...;JavaTeamName->Amit Java: JavaProgram ->JavaBook->Java->JavaProgram  
NSArray Count Example
is: 2010-10-05 15:26:05.700 method[1117:207] array = 1 2010-10-05 15:26
how do i grab the url in php?
how do i grab the url in php?  I want to grab the 'entire' url, including any special characters like & and #, from a site. I then want to replace the characters with something a browser can read for example: & = %26
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads