Question: Given a stacks, and the following method, what is the output of test (Racecar); ? public boolean test(String t) { Stack s = new

Given a stacks, and the following method, what is the output of   

Given a stacks, and the following method, what is the output of test ("Racecar"); ? public boolean test(String t) { Stack s = new Stack(); Stack u = new Stack(); for(int j = 0; j < t.length(); j++) s.push(t.charAt(j)+""); - for (int k t.length() 1; k >= 0; k--) u.push(t.charAt(k)+""); } while (!s.isEmpty() && !u.isEmpty()) { String s1 = (String) s.pop(); String u1 = (String) u.pop(); if(!(s.pop().equalsIgnoreCase(u.pop())) return false; } return true;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The output of testRacecar would be true Heres the explanation 1 The test method takes a string t as ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!