You are on page 1of 1

PRACTICAL TEST

Subject: Java by Example


Duration: 60 minutes

Create an abstract class named Student that stores the following details:
- Two string variables named rollno and name
- Abstract method named input()

Create a Student1 class extends from Student class.


This class has an integer variable named engMark and must override the input method.
In this method, prompt the user to enter the roll number, name and mark of English.

Create a class named Student2, extends from Student1 class.


This class has an integer variable named mathMark and overrides the input method.
This method must have the statement to call the input method of its parent class, and
prompt the user enters the mark of Mathematic.

Final, create a main class named TestStudent, it declares the following variables:
- studentCount: the number of the actual student in the array (static)
- Student2 [] arr: store array of Student2.

1 constructor with no parameter to initialize: studentCount =0 and arr which has 10


elements.
This class also implements the following methods:
- Get method to get value of studentCount.
- addStudent() method: this method create a new student, calls the input method
and adds this student to the array. If the maximum length of the array is reached
then a message is displayed to the user.
- displayPassStudents() method: print out the details of the students in the array
with the mark of English greater 15 and the mark of Mathematic greater 12

Use the switch-case and loop statements to displays a following menu and allows
exiting the application if only exit function is chosen.
1. Add Student
2. Display the pass-students
3. Exit

You might also like