Skip to main content

Posts

Showing posts with the label Day 12: Inheritance Hackerrank Solution in Java

Day 12: Inheritance Hackerrank Solution Java

 Day 12: Inheritance Hackerrank Solution Java For Explanation: Sample Input Heraldo Memelli 8135627 2 100 80 Sample Output Name: Memelli, Heraldo ID: 8135627 Grade: O Code: import  java.util.*; class  Person {      protected  String firstName;      protected  String lastName;      protected   int  idNumber;           // Constructor     Person(String firstName, String lastName,  int  identification){          this .firstName = firstName;          this .lastName = lastName;          this .idNumber = identification;     }           // Print person data      public   void  printPerson(){          System.out.println(                  "Name: "  + lastName +  ", "  + firstName              +    "\nID: "  + idNumber);      }       } class  Student  extends  Person{      private   int [] testScores;     Student(String firstName,String lastName, int  idNumber, int [] scores){          super (firstName,lastName,idNumber);          this .testScores = scores;     }