Home Answers Viewqa Java-Beginners what is wrong in this program......

 
 


Amit
what is wrong in this program......
1 Answer(s)      2 years and 3 months ago
Posted in : Java Beginners

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 Pages:
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
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 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 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'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
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 function computeGrade( ) { var hw, lab, midt, fin, avg; hw = parseFloat
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 is the rong
what is the wrong with this program......without changing the style of the code...what is the rong  Write a JAVA program to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each
wrong year
wrong year  hello I m using the following code: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy"]; NSDate *date... wrong year..   I think u are using other calendar Check Settings
recursion program
would be appreciate it because i cant see what im doing wrong. public class... trying for hours to do this program. it is a recursion problem where the user will enter a continuous monthly investment, at a rate of 1% the program should say
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
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 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
Java Program
clues, as to what the word is Given the clues, you have to work-out the word...) and hence 2 bulls. The other 'A' in the guess-word is present in the wrong place... and the number of cows and bulls for each word, your program should be able to work out
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
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
Java program? - Java Beginners
Java program?  In order for an object to escape planet's.... The escape velocity varies from planet to planet.Create a Java program which calculates the escape velocity for the planet. Your program should first prompt
What is JavaScript?
What is JavaScript?  Hi, Sometime the students trying to know make there career in Java. For java programming beginners always try to know What is Java script and other java related queries. How to define what is JavaScript
what is the server
what is the server  what is the server?   Server: A computer, or a software package, that provides a specific kind of service to client... so that additional capabilities can be added to the main program by adding
What is JDBC?
What is JDBC?  hello, What is JDBC?   hello, JDBC... for connecting the database from Java program. JDBC API provides the API... views, Stored procedures from Java program. Learn in detail at JDBC Tutorial page
what is the output?
what is the output?  public class MyAr{ public static void main(String argv[]) { int[] i=new int[5]; System.out.println(i[5]); } }   ... Program is: public class MyAr{ public static void main(String argv
jsp/servlet login program - JSP-Servlet
; and ("password")%>"/>. what could be wrong,i have coded the servlet.and the loginbean... a login program where a new user will be registered and his/her details stored
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 JavaScript Variables ?
What is JavaScript Variables ?  Hi, My question is that What is Variable in JavaScript Programming Language. How to declare variables in JavaScript Program. Thanks
What is struts - Struts
What is struts  What is struts?Please tell me in simple language for what struts is used, it is necessary to learn it can we have some alternate for struts?What should we need to make a program in struts. Thanks
What are Google Penguin Update Issues?
and not for search engines. What people do is use SEO tricks to gain ranking
Deleting Rows From Table
easily through our program, what we need is a simple query. ...;  Consider a situation where we have entered some wrong... of the program should be such,  if in future there is any need to make any
j2me program
j2me program  how to run j2me program?what setting is to do whem we run j2me programs?   Please go through the following link: J2ME Tutorials
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
What is meant by embedded SQL?
What is meant by embedded SQL?  What is meant by embedded SQL?   Hi, Embedded SQL statements are embedded with in application program and are prepared during the program preparation process before the program
what is this.. - Java Beginners
what is this..  what is the differece between platform independant and platform dependant?  Hi Friend, Difference: Platform Independent means not restricted to particular Opearting System environment from program
What is javascript Arrays?
What is javascript Arrays?   Hi, I am learner of JavaScript. My question is that What is JavaScript Arrays ? How to Define the JavaScript arrays in you program. Please give an example show that i will try my self. Thanks
What is the Locale class?
What is the Locale class?  What do you understand about locale class in java program. thanks,   Hi, The Locale class in Java is Java... is called locale-sensitive. For details visit What is Locale class in Java
What is the List interface?
What is the List interface?  Hi, What is the List interface... by their integer indes and sear for elements in the list. For details visit What is list Interface in Java Program
What is a file Separator?
What is a file Separator?  What is a file separator in Java Program?   Hi, The file separator is nothing but a character that we used to separate directory path names for a particular location. These file separator
What is numeric promotion?
What is numeric promotion?   Hi, What is numeric promotion? Thanks,   Hi, The numeric promotion in java used to convert the smaller number type to larger numeric types. In numerical promotion in java program we
netbeans program
) at that time. 3) Lending an item: When selected, the program should ask what is being...: When selected, the program should ask what is being returned. It should... with books. A Graphical User Interface (GUI) is not required, i.e. your program
What is Applet? - Applet
What is Applet?  What is Applet?  Hi,Here is a little... programming language, an applet is a small program that can be sent along with a Web.... Applet viewer is a command line program to run Java applets. It is included
What is Java Client Socket?
What is Java Client Socket?  Hi, What is client socket in Java programming? Please suggest any reference or examples. Thanks,   Hi... class passing two arguments as hostName and TIME_PORT. This program throws
Problem in running first hibernate program.... - Hibernate
Problem in running first hibernate program....  Hi...I am using... programs.It worked fine.To run a hibernate sample program,I followed the tutorial below... the zip file given in the link below and did what was given there.But it reported
what is meta data in java
in that database; the program knows exactly what kind of data it is dealing...what is meta data in java  what is meta data in java   Use ArrayList when there will be a large variation in the amount of data that you
code for program
code for program  hello,I am new to java and need to get the code for a program,i've been trying all sorts of code and nothing works any help would be appreciated.Below is what the program should output with the user's input
what is the error - Java Beginners
what is the error  What is the compile time error that i am getting while compiling the application. Thanks!  SOLUTION :- Your program... : "+ data);}}this program will also show such type of error ? DATA HAS
What is XML?
What is XML? In the first section of XML tutorials we will learn the basics... on "What is XML?" you will be able understand the XML document and create well formatted XML document. What is XML Document? Some facts about XML