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

Mutability vs Immutability in Java

This document provides instructions for a lab exercise on implementing the concepts of mutability and immutability in classes. Students are asked to create mutable and immutable classes to represent promoted and failed students respectively, with attributes like roll number, subject code, and name. The mutable class can be changed after object creation, while the immutable class cannot. A main class will demonstrate printing the attributes of objects from these classes.

Uploaded by

Muhammad Hamza
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)
21 views2 pages

Mutability vs Immutability in Java

This document provides instructions for a lab exercise on implementing the concepts of mutability and immutability in classes. Students are asked to create mutable and immutable classes to represent promoted and failed students respectively, with attributes like roll number, subject code, and name. The mutable class can be changed after object creation, while the immutable class cannot. A main class will demonstrate printing the attributes of objects from these classes.

Uploaded by

Muhammad Hamza
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

SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY

SOFTWARE CONSTRUCTION & DEVELOPMENT


LAB # 08
Mutability and Immutability

Objective: Understanding and implementing the concept of mutability and immutability.

 Apply concept of mutability and immutability for the task promoted and failed students.
The roll number, subject code, and subject name would have to be entered at time of object
creation and with getter method these variables should be printed. (Hint: Those students
who are failed in previous semester will be registered in immutable class, and promoted
students are registered in mutable class)
Source Code:
• Mutable Class

 Immutable Class:

Name : [Link] Khan Roll No 2019-SE-271 Section : F Page | 1


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
SOFTWARE CONSTRUCTION & DEVELOPMENT

1. Main Class:
Output:

Name : [Link] Khan Roll No 2019-SE-271 Section : F Page | 2

You might also like