Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Define an interface TwoStrings Oper declaring a function apply which takes two strings and returns a string. Then, define four classes implementing this interface,
Define an interface TwoStrings Oper declaring a function apply which takes two strings and returns a string. Then, define four classes implementing this interface, where the operation on strings returns: their concatenation (class Concat); their concatenation, but in the reverse order(class Concat Rev); a string consisting of the first letters of the two strings (class Initials); their concatenation, but separated by a separator passed to the constructor (class Separ). The following main function public static void main(String[] args) { TwoStringsOper [] a = { }; new Concat(), new ConcatRev(), new Initials (), new Separ(" loves ") for (TwoStringsoper op: a) { download InterS.java System.out.println(op.apply("Mary", "John")); } } should print: MaryJohn JohnMary MJ Mary loves John
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres how you can define the interface TwoStringsOper and the four classes that implement this inter...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started