Question 4:
(2 marks) The interface IFile below is already compiled and given in byte code format, thus you can use
it without creating IFile.java file.
public interface IFile {
5 of 5
Paper No: 3
}
public String fl(String str);
public String f2(String str);
Write a class named MyFile, which implements the interface IFile. The class MyFile implements
methods fl and f2 in IFile as below:
. f1: Returns the extension of the string which represent a path of file. If the string don't have the
extension of file return "wrong format".
•
f2: Return the new file name of the string which represent a path of file, with uppercase and add
prefix "New_" at the begin of file name, in otherwise return "wrong format".
The program output might look something like:
Enter file path:
c:\MyFile\data.txt
1. Test fl
2. Test f2
your choice:
1
Enter file path:
c:\Myfile\data.txt
1. Test fl
2. Test f2
your choice:
2
Zoom
- FUO
+ 100%
Close