Select The Appropriate Code Which Reverses A Word #262
Select the appropriate code which reverses a word.
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Application of Stacks - Towers of Hanoi - Quiz No.1.
Select the appropriate code which reverses a word.
public String reverse(String input) { for (int i = 0; i < input.length(); i++) { stk.push(input.charAt(i)); } String rev = ""; while (!stk.isEmpty()) { rev = rev + stk.peek(); } return rev; }
public String reverse(String input) { for (int i = 0; i < input.length(); i++) { stk.push(input.charAt(i)); } String rev = ""; while (!stk.isEmpty()) { rev = rev + stk.pop(); } return rev; }
public String reverse(String input) { for (int i = 0; i < input.length(); i++) { stk.push(input.charAt(i)); } String rev = ""; while (!stk.isEmpty()) { rev = rev + stk.pop(); } }
public String reverse(String input) { for (int i = 0; i < input.length(); i++) { stk.push(input.charAt(i)); } String rev = ""; while (!stk.isEmpty()) { rev = rev + stk.pop(); stk.pop(); } return rev; }
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes