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

Experiment No.1 Title:: To Study and Implement Class and Object in Java

The document describes an experiment to study and implement classes and objects in Java. It defines a Student class with attributes like name, marks, section, address, and mobile. It then creates an array of 5 Student objects, sets their attribute values, and prints out details of each student like their name, section, and marks.

Uploaded by

Gaurav
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)
34 views2 pages

Experiment No.1 Title:: To Study and Implement Class and Object in Java

The document describes an experiment to study and implement classes and objects in Java. It defines a Student class with attributes like name, marks, section, address, and mobile. It then creates an array of 5 Student objects, sets their attribute values, and prints out details of each student like their name, section, and marks.

Uploaded by

Gaurav
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

Experiment No.

Title: To study and implement class and object in java.

import java.io.*;
class PrintStudent
{
public static void main(String s[])
{
Student students[] = new Student[5];

students[0] = new Student();


students[0].name = "ABC";
students[0].marks = 45;
students[0].section = 'A';

students[1] = new Student();


students[1].name = "XYZ";
students[1].marks = 78;
students[1].section = 'B';

students[2] = new Student();


students[2].name = "PQR";
students[2].marks = 83;
students[2].section = 'A';

students[3] = new Student();


students[3].name = "LMN";
students[3].marks = 77;
students[3].section = 'A';

students[4] = new Student();


students[4].name = "UVW";
students[4].marks = 93;
students[4].section = 'B';

for(int i = 0; i < students.length; i++)


{
System.out.println( students[i].name + " in section " + students[i].section + " got "
+students[i].marks + " marks." );
}
}
}
class Student
{
String name;
int marks;
char section;
String address;
String mobile;
}

Output:-

You might also like