CODE BOARD TECHNOLOGIES – Fresher Interview Questions with answers
This blog explains codeboard technology interview questions with answers. Some of the questions are explained clearly below :
_______________________________________________________________________________
1. Write java program to count words without inbuilt functions ?
INPUT: code board is best code board is best
OUTPUT: code:2 board:2 is:2 best:2
Length Of The String Without Using Java Built In Length Method :
Java Code With Example
Java make the things easy as it provides the built in length method for the String class (java.lang.String) which is a final class .
for example :
String demo = ” This is a Java built-in method example “
int length= demo.length();
Then there is also a way to calculate the length of the string
You can count characters in two ways.
- Including space
- Excluding space
Below there are 2 programs to count characters in a string, I hope this might help you.
1.Program to count characters in a string including space
- import java.util.Scanner;
- public class Program
- {
- public static void main(String[] args)
- {
- System.out.println(“Enter the String”);
- Scanner scan=new Scanner(System.in);
- String input = scan.nextLine();
- char [] ch = input.toCharArray(); // converts string into character array
- System.out.println(ch.length); // prints the character count including space
- }
- }
2.Program to count characters in a string Excluding space
- import java.util.Scanner;
-
public class Program
-
{
-
public static void main(String[] args)
-
{
-
System.out.println(“Enter the String”);
-
Scanner scan=new Scanner(System.in);
-
String input = scan.nextLine();
-
char [] ch = input.toCharArray();
-
int count=0;
-
for (int i = 0; i < ch.length; i++)
-
{
-
if (ch[i]!=‘ ‘)
-
{
-
count++;
-
}
-
}
-
System.out.println(count++);
-
}
-
}
_______________________________________________________________________________
REFERENCES :
https://www.quora.com/How-do-I-count-characters-in-a-string-in-Java-without-using-charcount
Prepare Effectively with Code Board Technology Interview Questions and Answers
By preparing for the Code Board Technology interview questions and answers helps you get a solid foundation for your upcoming interviews. This blog covers the core programming concepts, logical reasoning, and problem-solving skills. By practicing these questions, you can familiarize yourself with the problems you might encounter in an interview and help to develop the skills to tackle the interview. Try to review regularly by solving the questions that we have mentioned above and the interview questions that we have provided in related blogs, so that you will be able to improve your confidence and technical knowledge for clarity.