In: Computer Science
Solution:
The answer will be "True"
Explanation:
=>In the code snippet given, isGreater(s1, s2) is a method which takes two parameters s1 and s2 of string type and returns true if s1 comes after s2 considering lexicographical order otherwise returns false.
=>In the main() function isGreater("before", "back") is called so s1 = before and s2 = back.
=>Now string s1 and s2 will be compared. As the first character of both the strings is same so second character will be checked, as character "e" comes after character "a" hence string s1 comes after s2.
=>As s1 comes after s2 so the if condition becomes true of the isGreater(s1, s2) method and isGreater(s1, s2) method will return true.
=>Now in the main() method if condition will be true because isGreater(s1, s2) method has already returned true hence "I was true" will be the output using cout << "I was true";
I have explained each and every part with the help of statements attached to the answer above.