You are on page 1of 2

Assignment No.

01
Total Marks: 20
Semester: Fall 2022
Compiler Construction CS506 Due Date: 5th Dec, 2022

Instructions:

Please read the following instructions carefully before submitting assignment. It should be clear that
your assignment will not get any credit if:

 The assignment is submitted after due date.


 The submitted assignment does not open or file is corrupt.
 Assignment is copied (partial or full) from any source (websites, forums, students, etc.)
Strict action will be taken in this regard.
 The assignment format is other than Notepad.

Objectives:

The objective of this assignment is to provide hands-on experience of Java Programming concepts
including:

 Classes and Objects


 Default and Parameterized Constructors
 Member Functions and main function

For any assignment related query, contact at CS506@vu.edu.pk

Covered Lectures: Assignment no.1 is from 1-9 lectures.

Software (s) Used to develop Assignment


Note: Use Notepad or Notepad++ for coding and JDK package for java source code compilation and
running. Submit a single Test.java file including both classes(Student and Test) in one file(No
multiple or zip files allowed)
A video tutorial of JDK installation and configuration is given in course download section
Link: https://vulms.vu.edu.pk/Courses/CS506/Downloads/JDK_Installation.mp4
Problem Statement: Marks 20
Write a program in java that will have two classes i.e. Student and Test. Student class will have three

attributes (id, name and program) and methods of constructors, getters, setters and print etc. Test class

will have the main method in which you are required to create four objects of Student class and store

them in an array. You have to write code for error exception handling as well in case if the array index

is to be accessed out of bound.

Detail:

 Student class will have three attributes (id, name and program).

 Methods of Constructors i.e default and parameterized to initialize the attribute.

1. Default constructors: If an object of Student class is created without passing any parameter

default constructor should be executed and set the values of attributes (id, name, and program)

to your own student id, name and program.

2. Parameterized Constructors: When parameters are provided then parameterized

constructor will initialize the data members with the given values.

 If the first two characters of the program string for example BS does not match the first two

characters of Student id i. e BC457810241 then error should displayed as:

“Your program does not match your student Id”

 It should have getter and setter functions to get or set the values of any one attribute.

 print function of Student class should display the students object data store in the array list.

 Test class will have the main method in which you are required to create four objects of

Student class and store them in an Array.

 First object should be without providing the parameters so it should call the default

constructor.

 Display the data of all the four students using for loop with one more index i.e 0,1,2,3,4. On
index 4, the Index out of Bounds Exception should be displayed.

BEST OF LUCK

You might also like