fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. abstract class Student {
  8. String name; int standard;
  9.  
  10. abstract void getPercentage();
  11. static void getTotalNoOfStudents() {}
  12.  
  13. public Student() {}
  14. public Student(String name, int standard) {
  15. this.name=name; this.standard=standard;
  16. }
  17. }
  18.  
  19. class ScienceStudent extends Student {
  20. int ScienceMarks;
  21. public static int noOfStudents=0;
  22.  
  23. public ScienceStudent(String name, int standard, int ScienceMarks) {
  24. super(name, standard);
  25. this.ScienceMarks=ScienceMarks;
  26. }
  27.  
  28. public void getPercentage() {
  29. System.out.println(10000/ScienceMarks);
  30. }
  31. }
  32.  
  33. class HistoryStudent extends Student {
  34. int historyMarks;
  35. public static int noOfStudents;
  36.  
  37. public HistoryStudent(String name, int standard, int historyMarks) {
  38. super(name, standard);
  39. this.historyMarks=historyMarks;
  40. }
  41.  
  42. public void getPercentage() {
  43. System.out.println(10000/historyMarks);
  44. }
  45. }
  46.  
  47. class AllStudent {
  48. public static void main(String[] args) {
  49.  
  50. ScienceStudent abhi = new ScienceStudent("Abhishek",2,95);
  51. HistoryStudent raj = new HistoryStudent("Rajath",2,80);
  52. abhi.getPercentage();
  53. raj.getPercentage();
  54. }
  55. }
Success #stdin #stdout 0.05s 4575232KB
stdin
Standard input is empty
stdout
105
125