Design a package to contain class Student and package contain interface Sports
package pack1; public class Student { public int roll_no=25; public char name[]={'r','o','h','i','t'}; } package pack2; public interface Sports { void show(); } package Record; import pack1.*; import pack2.*; class sports1 implements Sports { public void show() { System.out.println("12/1/2012 - Football"); System.out.println("14/1/2012 - Cricket"); System.out.println("15/1/2012 - Tennis"); } } class Test { public static void main(String args[]) { Student s=new Student(); sports1 s1=new sports1(); System.out.print("Roll Number: "+s.roll_no+"\nName: "); System.out.println(s.name); s1.show(); } }
Output:
Roll Number:25
Name:rohit
12/1/2012 – Football
14/1/2012 – Cricket
15/1/2012 – Tennis