Tutorial 4
Tutorial 4
1. Imagine you are building a University class. You want to create a static nested class
Library to represent the university library and an inner class Department to represent the
departments within the university. The Library class should have a method to display the
library’s name, and the Department class should have a method to display the department’s
name.
2.In the context of a student management system, implement a Java program that
demonstrates file handling operations. The program should enable saving and retrieving
student details (such as name and age) to and from a file.
3.You are tasked with developing a text processing application that manipulates large strings
efficiently. The application needs to perform various string operations such as concatenation,
reversal, and replacement. Given the requirement, you need to demonstrate the usage and
differences between StringBuilder, String, and StringBuffer in Java.
Requirements:
String Concatenation:
Implement a method to concatenate multiple strings using String, StringBuilder, and
StringBuffer.
Measure and compare the performance of each approach for concatenating a large number of
strings.
String Reversal:
Implement a method to reverse a string using StringBuilder and tringBuffer.
Compare the ease of use and performance of each approach.
String Replacement:
Implement a method to replace all occurrences of a substring within a string using
StringBuilder, String, and StringBuffer.
Highlight the differences in immutability and thread-safety.