Answered step by step
Verified Expert Solution
Link Copied!

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,

image text in transcribed 


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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Physics

Authors: Alan Giambattista, Betty Richardson, Robert Richardson

2nd edition

77339681, 978-0077339685

More Books

Students also viewed these Physics questions

Question

assume the tax rate for all c-corporations is 21%

Answered: 1 week ago

Question

Explain the regulation of the secretions of the small intestine.

Answered: 1 week ago