what is wrong in this program......

what is wrong in this program......

program to implement given inheritance

import java.io.*;
class Student
{
  int rno;
  String name;
  DataInputStream ob = new DataInputStream(System.in);
  void getRoll()
  {
    System.out.println("Enter Name:");
    name=ob.readLine();
    System.out.println("Enter Roll No.");
    rno=Integer.parseInt(ob.readLine());
  }
}
class Test extends Student
{
  float m1,m2;
  void getMarks()
  {
    System.out.println("Enter Sem1 Marks");
    m1=Float.parseFloat(ob.readLine());
    System.out.println("Enter Sem2 Marks");
    m2=Float.parseFloat(ob.readLine());
  }
}
interface Sports
{
  void getScore();
  void display();
}
class Result extends Test implements Sports
{
  float Score;
  public void getScore()
  {
    System.out.println("Enter Sports Score");
    Score=Float.parseFloat(ob.readLine());
  }
  float total;
  void getTotal()
  {
    total=m1+m2+Score;
  }
  public void display()
  {
    System.out.println("Name Of Student Is:"+name);
    System.out.println("Roll No.-"+rno);
    System.out.println("Sem1 Marks Are:"+m1);
    System.out.println("Sem2 Marks Is:"+m2);
    System.out.println("Sports Score Is:"+Score);
    System.out.println("Total Score Is:"+total);
  }
}
class Inheritance2
{
  public static void main(String args[])
  throws IOException
  {
    Result obj=new Result();
    obj.getRoll();
    obj.getMarks();
    obj.getScore();
    obj.getTotal();
    obj.display();
  }
}
View Answers

March 30, 2011 at 12:26 PM

import java.io.*;
class Student { 
    int rno;
    String name; 
    DataInputStream ob = new DataInputStream(System.in);
    void getRoll() { 
        try{
        System.out.println("Enter Name:");
        name=ob.readLine(); 
        System.out.println("Enter Roll No.");
        rno=Integer.parseInt(ob.readLine()); 
        }
        catch(Exception e){}
        } 
        } 
        class Test extends Student {
            float m1,m2; 
            void getMarks() {
                try{
                System.out.println("Enter Sem1 Marks");
                m1=Float.parseFloat(ob.readLine());
                System.out.println("Enter Sem2 Marks");
                m2=Float.parseFloat(ob.readLine());
                }
                catch(Exception e){}
                }
                }
                interface Sports {
                    void getScore(); 
                    void display();
                    }
                    class Result extends Test implements Sports {
                        float Score; 
                        public void getScore() {
                            try{
                            System.out.println("Enter Sports Score");
                            Score=Float.parseFloat(ob.readLine());
                            }
                            catch(Exception e){}
                            } 
                            float total; 
                            void getTotal() {
                                total=m1+m2+Score; 
                                } 
                                public void display() { 
                                    System.out.println("Name Of Student Is:"+name);
                                    System.out.println("Roll No:"+rno); 
                                    System.out.println("Sem1 Marks Are:"+m1);
                                    System.out.println("Sem2 Marks Is:"+m2);
                                    System.out.println("Sports Score Is:"+Score);
                                    System.out.println("Total Score Is:"+total); 
                                    } 
                                    } 
                                    class Inheritance2 {
                                        public static void main(String args[]) throws Exception { 
                                            Result obj=new Result();
                                            obj.getRoll();
                                            obj.getMarks(); 
                                            obj.getScore();
                                            obj.getTotal(); 
                                            obj.display();
                                            }
                                            }









Related Tutorials/Questions & Answers:
what is wrong with this program
what is wrong with this program  import java.io.*; class Distance { int feet,inch; void read() { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine()); inch
what is wrong in this program......
what is wrong in this program......  program to implement given inheritance import java.io.*; class Student { int rno; String name; DataInputStream ob = new DataInputStream(System.in); void getRoll
Advertisements
what is wrong in this program
what is wrong in this program  import java.io.*; class Distance { int feet; int inch; void read(int feet, int inch) { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine
What is wrong with this line
What is wrong with this line  What is wrong with this line JOptionPane.showMessageDialog(null? for Using Lewandowski's Savings pgrm!"); from if (input.equals("exit") || input.equals("Exit")) { JOptionPane.showMessageDialog
What is wrong with my servlet?
What is wrong with my servlet?  I'd like to know which part of the code is wrong. My code is: print("code sample"); import java.util.*; import java.io.IOException; import java.io.PrintWriter; import
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.  import java.io.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List
what is wrong with my JSP codes for updating a form?
what is wrong with my JSP codes for updating a form?  Hi experts, I have tried to emulate a code from a textbook but it doesn't work in my program. Hope someone can advise me where I had gone wrong. Tks. I've set up my
What's wrong with my form? - Java Beginners
What's wrong with my form?  Dear expert, I'm having trouble with my enquiry form. Hope you can tell me where my mistake lies. Thanks. Here's my jsp code: Enquiries var objForm = new Object
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've tried the following codes which I have copied from Java Ranch forum and deleted...))"; But, none is working out. Hope you can tell me what's the query to use. Many
what's the logic for create pattern program
what's the logic for create pattern program   1 2 3 4 5 5 1 2 3 4 4 5 1 2 3 3 4 5 1 2 2 3 4 5 1
What is the real use of Java Program
to know more in Java programming. What is the real use of java program? Just...What is the real use of Java Program  Hi, I am complete beginner..., servers, desktop, mobile devices and embedded systems. With the help of Java program
What is the real use of Java Program
to know more in Java programming. What is the real use of java program? Just...What is the real use of Java Program  Hi, I am complete beginner..., servers, desktop, mobile devices and embedded systems. With the help of Java program
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
What is the answer and how the program work?
What is the answer and how the program work?  public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw... is the out put of the program
ModuleNotFoundError: No module named 'wrong'
ModuleNotFoundError: No module named 'wrong'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'wrong' How to remove the ModuleNotFoundError: No module named 'wrong'
wrong year
wrong year  hello I m using the following code: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy"]; NSDate *date... wrong year..ADS_TO_REPLACE_1   I think u are using other calendar Check
c programming..what wil be the output of this program
c programming..what wil be the output of this program   #include int main() { int arr[] = {0,1,2,3,4}; int i,*ptr; for (ptr=arr+4; ptr= arr; ptr--) { printf("%d",*ptr
Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades ADS_TO_REPLACE_1 function computeGrade( ) { var hw, lab, midt, fin, avg; hw
error cannot access class com.opensymphony.xwork2.ActionContext, wrong version
error cannot access class com.opensymphony.xwork2.ActionContext, wrong version  Error(1,32): cannot access class com.opensymphony.xwork2.ActionContext; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0
What is the use of BufferedReader in Java program?
Learn about BufferedReader class and understand "What is the use of BufferedReader in Java program?" In this article I will explain you the benefits and uses... and lines. If you are writing a program to read a text file then you can use
program
program  Hi.. Good Morning Please say me whts wrong in this application import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.io.*; public class DBServlet extends HttpServlet { public void
Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column
Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column
Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column
program
program  any program of hotel or school management
program
program  program of jdbc using ms access for creating table
program
program  write a javascript program to create a application form with validation
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = â??Tommyâ?? age=â??23â?? and call this constructor
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
according to me its ok but is calculating wrong values in
according to me its ok but is calculating wrong values in   program to calculate roman numbers .....i.e roman number calculator import java.util.*; import java.io.*; class romancalci { public static void main(String
What are Google Penguin Update Issues?
and not for search engines. What people do is use SEO tricks to gain ranking

Ads