Most Asked Coding Questions In IT Companies

Frequently asked Questions in the Technical round of the IT Companies.

1. Program to print the String in Reverse.

package iamAlien;
import java.util.Scanner;
public class Alien {
public static void main(String[] args)
{
      Scanner sc = new Scanner(System.in);  
      System.out.println("Enter Any String without Space: ");
      String reverse ="";
      String str = sc.nextLine();
      for(int i=0; i<str.length(); i++)
      {
    reverse = str.charAt(i) + reverse;
      
      }
      System.out.println(reverse);
}
}

2. Program to count the occurring a particular Alphabet in the word taken by the User.

package iamAlien;
import java.util.Scanner;
public class Alien {
public static void main(String[] args)
{
      Scanner sc = new Scanner(System.in);  
      System.out.println("Enter Any your Sentence: ");
      String str = sc.nextLine();
      System.out.println("Enter the Alphabet Which you want to Count:");
      char alp =sc.next().charAt(0);
      int count=0;
      for(int i=0; i<str.length(); i++)
      {
    if(alp == str.charAt(i))
    {
    count++;
    }
      
      }
      System.out.println(count);
}
}

3. Check whether the String is Palindrome or Not.

package iamAlien;
import java.util.Scanner;
public class Alien {
public static void main(String[] args)
{
      Scanner sc = new Scanner(System.in);  
      System.out.println("Enter Any your String ");
      String str = sc.nextLine();
      String reverse ="";
      for(int i=0; i<str.length(); i++)
      {
         reverse = str.charAt(i)+reverse;
      }
      if(reverse.equals(str))
      System.out.println("String Is Palindrom");
      else 
      System.out.println("String is Not Palindrom");
}
}

4. Count the Total Numbers of Vowels and Consonants in the String.

package iamAlien;
import java.util.Scanner;
public class Alien {
public static void main(String[] args)
{
      Scanner sc = new Scanner(System.in);  
      System.out.println("Enter your String ");
      String str = sc.nextLine();
      char c;
      int c1=0,c2=0;
      for(int i=0; i<str.length(); i++)
      {
         c = str.charAt(i);
         if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        c1++;
         else
        c2++;
         
      }
      System.out.println("Vowels Are:"+c1);
      System.out.println("Consonants Are:"+c2);
}
}

Comments

Popular posts from this blog

Remove Tools From Termux | How can I reopen the installed tool in termux? | TECH WORTHY MIND

How To Hack Wifi | Hack Wifi Password | TECH WORTH MIND