abstract
class MyAbstract { public static void main( String[ ] args ) { // Create an object of the Student class, // which inherits attributes and methods from Person. Student myStudent = new Student( args[0] ); myStudent.graduationYear = Integer.parseInt( args[1] ); System.out.print( myStudent.fname + " " ); System.out.print( myStudent.graduationYear + " " ); myStudent.study( ); // call abstract method } }
// Abstract class abstract class Person { public String fname; Person( String name ) { fname = name; } // Constructor public abstract void study( ); // Abstract method }
// Subclass (inheriting from Person) class Student extends Person { public int graduationYear; // Constructor Student( String name ) { super( name ); } // The body of the abstract method is provided here. public void study( ) { System.out.print( "24/7" ); } }