0% found this document useful (0 votes)
5 views2 pages

Classroom

The document contains a Java class definition for managing a collection of students in a classroom setting. It includes constructors for initializing class attributes such as standard, section, teacher, and maximum seats, as well as methods for reading student data and printing class information. The class utilizes an array of 'Student' objects to store and manage individual student details.

Uploaded by

golyanpanav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Classroom

The document contains a Java class definition for managing a collection of students in a classroom setting. It includes constructors for initializing class attributes such as standard, section, teacher, and maximum seats, as well as methods for reading student data and printing class information. The class utilizes an array of 'Student' objects to store and manage individual student details.

Uploaded by

golyanpanav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

File: Untitled Document 1 Page 1 of 2

import java.util.*;
/**
* Abstraction
*
*
*/
public class Class
{
/**
* CLASS is the collection of students
*/

int std;
char sec;
Student [] students;
String teacher;
int strength;
int max_seats;
/**
* Constructor method is called only once in one object
* It helps in creating an object
* Constructor methos has the name of the class
* Methods don't have any output / return type
* Functions are different by the type of formal parameter
*/

//Parameterised constructor
public Class(int std)
{
this.std = std;
}

//Parameterised constructor
public Class (char sec)
{
this.sec = sec;
}

//This constructor assigns values to the instance variables


public Class(int std , char sec , int max_seats,String teacher)
{
this.std = std;
this.sec = sec;
this.teacher = teacher;
this.max_seats = max_seats;

students = new Student[max_seats];


}

//This function sets the data for each student in a given class
void read_class_data()
{
int n = 0;

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number of Students in the class");


n = sc.nextInt();

strength = n;

for(int i = 0; i<n;i+=1)
{
students[i] = new Student();
students[i].setData();
students[i].setAdmn_no();
File: Untitled Document 1 Page 2 of 2

}
}

//This function prints the class data


void print_class_data(int day , int month , int year)
{
System.out.println("Data for student" + ":");
System.out.println("Std:"+std+""+ sec);
System.out.println("Class Teacher:" + teacher);
System.out.println("Max Strength:" + max_seats);
for(int i = 0; i<strength;i+=1)
{
students[i].printFinal(day , month , year);
}
/**
* Output

* Data for student:


Std:10A
Class Teacher:Ritesh
Max Strength:2
Admn_no: Name: Surname:
1 Panav Golyan
The age is: 15years 6months 28days
Admn_no: Name: Surname:
2 Shreyansh Golyan
The age is: 19years 1months 27days
*/
}
}

You might also like