java inheritance

Ads
 

java inheritance

problem with following code....

class Employee { int empno; String name; String edesig;

Employee() { empno=0;

} Employee(int eno,String ename,String ed) { empno=eno; name=ename; edesig=ed; } public void disp() { System.out.println("The empno is:"+empno); System.out.println("The name is:"+name); System.out.println("The desig is:"+edesig);

} }

class salary extends Employee { double basic;

salary(int eno,String ename,String ed,double bas) { super(eno,ename,ed); basic=bas; }

public void calculate() { double sal,netsal; double da,hra,pf; da=basic*0.10f; hra=basic*0.15f; pf=basic*0.08f; sal=basic+da+hra; netsal=sal-pf; super.disp(); System.out.println("The net salary is:"+netsal);

} } class x { public static void main(String args[]) {

salary s1=new salary(123,"rty","ert",1300.00); s1.calculate(); } }

View Answers

June 11, 2012 at 4:54 PM

Your code works fine. There is no error at all. IF there is any query related to it then please mention it.

Ads









Related Tutorials/Questions & Answers:
Inheritance,Inheritance in Java,Java Inheritance
kinds of inheritance are there in java.   Simple Inheritance  .... Java does not support multiple inheritance but the multiple inheritance can be achieved by using the interface. In Java Multiple Inheritance can be achieved
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
Advertisements
java inheritance
java inheritance  problem with following code.... class Employee { int empno; String name; String edesig; Employee() { empno=0; } Employee(int eno,String ename,String ed) { empno=eno; name=ename
java inheritance
java inheritance  ACME Bike shop has created a new scheme to reward employees for selling bicycles. Sales are only made by either, a sales person...% and to the sales agents at a rate of 10%. Write a Java application
Concept of Inheritance in Java
Concept of Inheritance in Java Concept of Inheritance in Java is considered... class from parent class. Let's understand the concept of inheritance in Java... that is used for reusability purpose. There are three types of inheritance in java
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
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
Java Inheritance Concept.
Java Inheritance Concept.  Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Inheritance java Example
Inheritance java Example  How can we use inheritance in java program?   class Animal { public void eat(String str... of inheritance. Inheritance is a way of establishing a subtype from an existing object
inheritance
inheritance  how does one implement inheritance in java
Java code to implement MULTIPATH INHERITANCE
Java code to implement MULTIPATH INHERITANCE  HI, I am new to java programming. I want to implement multipath inheritance in one java program...(Hierarchical and Multiple inheritance) Thanks in advance
Does Java support multiple inheritance?
Does Java support multiple inheritance?  Hi, Does Java support multiple inheritance? thanks   hi, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Hope
Inheritance Example In Java
Inheritance Example In Java In this section we will read about the Inheritance... the Inheritance in Java the Multiple inheritance is not supported. This reduces... the inheritance feature in Java programming. This example will demonstrate you
Java code to implement MULTIPATH INHERITANCE
Java code to implement MULTIPATH INHERITANCE  Hi, I am new to java .so please write code for this inheritance example... Student | ----------- | | Test Sports
Multilevel Inheritance in java
Multilevel Inheritance in java We are going to discuss about multilevel inheritance in java. The Multilevel inheritance is inherit of classes more than two... Inheritance in java package Inheritance; class Animal { private int
Inheritance in Java with example
Here we are going to discuss Inheritance in Java with a simple example... for inheritance in Java. Inheritance is used in java for the reusability of code... of java.lang.Object.java. Java supports three types of inheritance, they are: Simple
Java : Multilevel Inheritance
Java : Multilevel Inheritance This section contains concept of multilevel Inheritance in java. Multilevel Inheritance : In multilevel inheritance more than... can say multilevel inheritance create one-to-one ladder. Now you can access
Inheritance program in java
In this tutorial we will discuss examples of Simple Inheritance in Java and Multilevel Inheritance in Java. Inheritance is an OOPS (Object Oriented... in Java. The concept of inheritance is used to make the things from general to more
doubt in inheritance program - Java Beginners
doubt in inheritance program  how will we get the result 6 2 5 in the inheritance program in the given example i got 6 &2 but i am confused about 5
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 in Java
Inheritance in Java enhances the properties of the class, which means... of inheritance in Java: Simple Inheritance Multilevel Inheritance... of level. * Though Java does not support Multiple Inheritance it can be achieved
Inheritance in Java 7
This tutorial describe concept of Inheritance. It is one of OOPs concept
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
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
class so java any how do multiple inheritance? Can you please explain...Multiple Inheritance  All are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined
javascript inheritance framework
javascript inheritance framework  javascript inheritance framework
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

Ads