Answer:
See explaination for the program code.
Step-by-step explanation:
Replace the student names with names of your choice I used dummy names in the following program
Solution:
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
Student st=new Student();
st.setOfActivites();
}
}
class Person
{
//data member as specified in the question
String name;
//Below are methods specified in the question
void setName(String name)
{
this.name=name;
}
String getName()
{
return this.name;
}
}
class Student extends Person
{
void setOfActivites()
{
ArrayList<String> students=new ArrayList<String>();
//b) in the question i.e. enrolling 10 students
students.add("a");
students.add("b");
students.add("c");
students.add("d");
students.add("e");
students.add("f");
students.add("g");
students.add("h");
students.add("i");
students.add("j");
//c)Appending another student
students.add("z");
//d)Inserting student at beginning of the list
students.add(0, "x");
//e)Finding number of students
int n=students.size();
System.out.println("Number of students at present"+n);
//f)Removing a given student replace the index with your value of choice
int index=4;
students.remove(index);
//g)Retrieving student from a particular index
index=5;
System.out.println("Student at "+index+" is "+students.get(index));
//h)Checking for a student
boolean b=students.contains("a");
if(b)
System.out.println("Given student exists");
else
System.out.println("Given student does not exist");
//i)Printing the list of students
System.out.println("List of students is");
System.out.println(students);
//j)Clearing the list of students
students.clear();
}
}