Name: Mohamad Fasil Ansaary M Reg. No.: 19BCE1687 Course: CSE1007 Java Programming Lab Faculty: Dr. Hema N
Name: Mohamad Fasil Ansaary M Reg. No.: 19BCE1687 Course: CSE1007 Java Programming Lab Faculty: Dr. Hema N
1.Define a class University that has 2 member variables name of the university and place.
Define a method display to print the university details. Construct an interface that method
called subject() which is implemented into a class called School. Given the name of the
university, display the details and the subjects offered by them.
Source Code:
import java.util.*;
interface subject
class University
String name;
String loc;
this.name =name;
this.loc=loc;
void display()
{
System.out.println("\nUniversity Name: "+name);
System.out.println("Located at : "+loc);
String [] sub;
super(name,loc);
this.sub=new String[sub.length];
for(int i=0;i<sub.length;i++)
this.sub[i]=sub[i];
for(int i=0;i<sub.length;i++)
System.out.println(sub[i]);
int n;
String name;
String loc;
Scanner s=new Scanner(System.in);
name= s.nextLine();
loc= s.nextLine();
n=s.nextInt();
for(int i=0;i<n;i++)
sub[i]= s.nextLine();
ob.display();
ob.subjects();
Output:
2.Create 3 packages: student, academics, placement and non-academics (sub package of
academics) to read information and create a main package report to display required
information of the student.
Source Code:
package academics;
import java.util.Scanner;
package academics.nonacademics;
import java.util.Scanner;
package placements;
import java.util.Scanner;
package student;
import academics.*;
import academics.nonacademics.*;
import placements.*;
import java.util.Scanner;
package report;
import student.*;
import java.util.Scanner;
Output: