(packages) Design a package to contain the class Student that contains data members such as name, roll number and another package contains the interface Sports which contains some sports information. Import these two packages in a package called Report which process both Student and Sport and give the report.

package pack1;
public class Student
                        public int rol_no=18;
                        public char name[]={‘s’,’e’,’k’,’h’,’a’,’r’};
package pack2;
public interface Sports
            void show();
//Program to implement packages
package Record;
import pack1.*;
import pack2.*;
class sports1 implements Sports
            public void show()
                        System.out.println(“21/3/2011 – volley ball”);
                        System.out.println(“22/3/2011 – Cricket”);
                        System.out.println(“23/3/2011 – Table tennis”);
class Report
            public static void main(String args[])
                        Student s=new Student();
                        sports1 s1=new sports1();
                        System.out.print(“Rollnumber: “+s.rol_no+”nname “);
Rollnumber: 18
name sekhar
21/3/2011– volley ball
22/3/2011– Cricket

23/3/2011– Table tennis

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks