012-002-009

Building a Utility Class with Static Methods

Hard

Problem Description

Building a Utility class with static Methods

In this problem, you will create a program that implements three static methods in a StringUtil class (character counting, string reversal, and palindrome checking), processes a string read from Scanner, and displays the results to standard output.

Learning Objective: Understand designing utility classes with combined static methods

Overview

Define static methods in a StringUtil class to process strings.

Specifications

  1. StringUtil.countChar(String s, char c): Returns the count of character c in string s
  2. StringUtil.reverse(String s): Returns the reversed string
  3. StringUtil.isPalindrome(String s): Returns true if string is a palindrome
  4. Read one line from Scanner
  5. Print count of 'a', reversed string, and palindrome check

Input Example

racecar

Output Format

Count of 'a': 2
Reversed: racecar
Palindrome: true

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up