1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ber [7]
4 years ago
6

Write a recursive method that tests whether a string is a palindrome. It should return a boolean T or F depending on whether or

not the string is a palindrome,
Computers and Technology
1 answer:
Sveta_85 [38]4 years ago
8 0

Answer:

// program in java.

// library

import java.util.*;

// class definition

class Main

{

// recursive function to check palindrome

   public static boolean isPalin(String str){

// base case

     if(str.length() == 0 ||str.length()==1){

        return true;

     }

// if first character is equal to last

     if(str.charAt(0) == str.charAt(str.length()-1))

     {

     // recursive call

        return isPalin(str.substring(1, str.length()-1));

     }

     // return

     return false;

  }

  // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input

Scanner scr=new Scanner(System.in);

System.out.print("Enter a string:");

 // read string from user

String myString =scr.nextLine();

 // call function to check palindrome

     if (isPalin(myString)){

        System.out.println("Given String is a palindrome");

     }

// if string is not palindrome

     else{

        System.out.println("Given String is not a palindrome");

     }    

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read a string from user and assign it to variable "myString" with scanner object. Call the method isPalindrome() with string input parameter.In this method, if  length of string is 0 or 1 then it will return true(base case) otherwise it will call itself and compare first character with last character.If string is palindrome then function will return true else return false.

Output:

Enter a string:ababa                                                                                                      

Given String is a palindrome

You might be interested in
What is the first stage of perception
Zigmanuir [339]

If we do not attend to stimuli, then we cannot perceive stimuli; thus attention is a critical factor in the process of perception. Receiving and attending to stimuli is the first stage in perception. Once we collect stimulus information from the senses, we have to try to make sense of it. This is called organization.


8 0
3 years ago
Read 2 more answers
Hey does anyone know any sites like you tube i can watch on my school chrome book or tell me how to unblock sites cause everythi
Vera_Pavlovna [14]

Answer:

Simple

Explanation:

Phoenix browser

4 0
3 years ago
Before installing any software, it's always important to back up your system and to create a BLANK, which enables you to go back
g100num [7]
Whats the question supposed to be so I can answer it?
8 0
3 years ago
Read 2 more answers
based on your completed tables for ping requests and replies, which field do you think helps the network identify the appropriat
Ilia_Sergeevich [38]

Ping, a computer network management tool, is used to determine whether a host is reachable on an IP network. ARP protocols To begin, launch Wireshark and the ecet-375 Web Browsing. Pcap capture file. This capture file was created while browsing the Internet.

<h3>What does ping operates mean?</h3>
  • Ping sends an ICMP Echo Request to a predefined network interface and then waits for a response. A ping signal is sent to the specified address when a ping command is issued.
  • The destination host sends the echo reply packet in response to receiving the echo request.
  • A ping is the time it takes for a small data set to be communicated from your device to an Internet server and back to your device (latency is the more accurate technical word). Ping times are measured in milliseconds.
  • Ping is the most commonly used TCP/IP command for troubleshooting connectivity, reachability, and name resolution.
  • This command displays Help content when run without any parameters. You can also use this command to verify the computer's name as well as its IP address.

To learn more about ping operates, refer to:

brainly.com/question/14366813

#SPJ4

7 0
2 years ago
Some hardware can be added to the computer without having to restart or power down the computer. After a short period of time th
Alja [10]

Answer:

The answer is "Option c"

Explanation:

Plug and Play is a general term that is used to define gadgets operating with a computer network while connected to it. This technology allows the hardware to use automatically by adding it, and other option can be described as follows:

  • In option a, This technology is used in monitoring the commercial vehicles system, which is why it's incorrect.
  • In option b, It is wrong because It is used in Microsoft Windows, which increases the physical security.
  • In option d, It describes the details about the hardware and switches to configure the device, that's why it is incorrect.
5 0
3 years ago
Other questions:
  • . Find four different commands in Internet Explorer and identify their keyboard shortcuts. A. B. C. D.
    10·1 answer
  • Write a C++ program that overloads a function named LinearSearch that searches an array of data of either integer data type, flo
    8·1 answer
  • What is a fragmented disk?
    14·1 answer
  • An organization’s SOC analyst, through examination of the company’s SIEM, discovers what she believes is Chinese-state sponsored
    12·1 answer
  • What happens if the user sysadmin invokes the mail command interface and there are no unread mail messages?
    13·1 answer
  • Corinne is on a project team and they are in the project execution phase. She gets a call from a stakeholder to make a change to
    6·1 answer
  • Edhesive 6.2
    6·2 answers
  • Make a Flow Chart From this C Programming Language Code
    14·1 answer
  • What are the two main types of citing information?
    12·2 answers
  • During an IFR flight in IMC, you enter a holding pattern (at a fix that is not the same as the approach fix) with an EFC time of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!