Kizspy.me
OUTPUT:
17
5 0T,- \OET\ ?נט) (0;&T (פרנס
(3G1,12) (2H,5)
Add how many elements: 0
Enter TC(1-f1;2-f2;3-13): 3
The list before running f3:
(A2,10) (B2,56) (C3,10) (D6,47) (E6,56) (1F,15) (3G1,18)
(2H,25)
OUTPUT:
(B2,56) (D6,47) (E6,56) (1F,15) (3G1,18) (2H,25)
Question 4:
(2 marks) The interface IString below is already compiled and given in byte code format, thus you can
use it without creating IString.java file.
}
public interface IString {
public int f1(String str);
public String f2(String str);
Write a class named MyString, which implements the interface IString. The class MyString implements
methods f1 and f2 in IString as below:
•
f1: Returns the digit that appears most frequently in the string str. If there are multiple digits
with the same number of occurrences, returns the largest of them. If there are no digits, returns -
1.
•
f2: Reverses each group of consecutive digits in a string str while keeping all non-digit characters
in their original positions.
The program output might look something like:
Zoom
+100%
Close