Date d = new Date(new File("filename.txt").lastModified()); Creation date is forgotten after the file is modified so lastModified() is all you can get.
Both, trim() and toUpperString() create a new string object ONLY IF there a change is required in the original string otherwise, same object is returned. So, 2 returns false while 4 returns true.