Class 11

Class 11 MyString Program ISC 2020

A class MyString enables the user to accept a sentence and displays the words beginning and ending with the same alphabet.

Example: EXAMPLE begins and ends with the alphabet ‘E’.

Some of the members of the class are given below:
Class name: MyString
Data members/instance variables:
str: to store the sentence.
Member functions/methods:
MyString(): default constructor.
void accept(): to accept a sentence in uppercase.
boolean check(String s): checks the first and last character of the string ‘s’ and returns true if same, otherwise returns false.
void show(): displays the sentence along with the words beginning and ending with the same alphabet by calling the function check().

Define the class MyString giving details of the constructor, void accept(), boolean check(String) and void show(). Define the main() function to create an object and call the functions accordingly to enable the task.

class MyString{
    String str;
    public MyString(){
        str = "";
    public void accept()throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(;
        System.out.print("Enter the sentence: ");
        str = br.readLine();
        str = str.toUpperCase();
    public boolean check(String s){
        if(s.length() > 0){
            char first = s.charAt(0);
            char last = s.charAt(s.length() - 1);
            return first == last;
        return false;
    public void show(){
        System.out.println("Sentence: " + str);
        str = str + " ";
        String word = "";
        for(int i = 0; i < str.length(); i++){
            char ch = str.charAt(i);
                word = "";
                word += ch;
    public static void main(String args[])throws IOException{
        MyString obj = new MyString();

One reply on “Class 11 MyString Program ISC 2020”

Sir,2 programs are given which states that:
1) WAP in Python to accept a number.Now check whether it is automorphic or not using Recursion.
2)WAP in Python to accept a number.Now count the no.of digits present using for loop.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.