In this program, we will create a class Student with 3 data members id, name, and fee. Here, we will create methods to initialize and print data members. Then we will create 3 objects of the Student class and set and print student information.
In the above program, we created a class called Student. The Student class contains data member's id, name, and fee. Then we defined the initialize() method to initialize the data members and we also created a PrintStudentInfo() method to print student information. Then we created 3 objects of the class and initialized the data members and called PrintStudentInfo() method to print student information.
Program/Source Code:
The source code to create the multiple objects of the class is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created a class called Student. The Student class contains data member's id, name, and fee. Then we defined the initialize() method to initialize the data members and we also created a PrintStudentInfo() method to print student information. Then we created 3 objects of the class and initialized the data members and called PrintStudentInfo() method to print student information.
need an explanation for this answer? contact us directly to get an explanation for this answer