Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
11.2k views
in Computer by (49.9k points)
closed by

Design a class Change to perform string related operations. The details of the class are given below: 

Class name: Change 

Data Members/instance variables: 

str: stores the word 

newstr: stores the changed word 

len: store the length of the word 

Member functions: 

Change(): default constructor 

void inputword( ): to accept a word char caseconvert (char ch): converts the case of the character and returns it

void recchange (int): extracts characters using recursive technique and changes its case using caseconvert () and forms a new word 

void display (): displays both the words

(a) Specify the class Change, giving details of the Constructor ( ), member functions void inputword (), char caseconvert (char ch), void recchange (int) and void display (). Define the main () function to create an object and call the functions accordingly to enable the above change in the given word.

(b) Differentiate between an infinite and a finite recursion.

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

(a) import java.io.*; 

Class change 

String str; 

String newstr;

int len; 

public change() 

str = " " ; 

newstr = " "; 

len = 0; 

public void inputword() 

BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); 

System.out.println ("Enter the number"); 

Str=br.readLine(); 

public char caseconvert (char ch) 

if (ch > = 'A' &&. ch = 'a' && ch < = 'z') 

return (char) ((int) ch - 32); 

if (ch = = ' ') return ch; 

public void recchange (int a) 

if(a<0) return; 

else recchange (a-1);

(b) Finite recursion has the same stopping condition on which the recursive function does not call itself. Infinite recursion has no stopping condition and hence go on infinitely.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...