String Interview Questions And Answers

String Interview Questions list for experienced

  1. How to generate a random alpha-numeric string?
  2. Why is char[] preferred over String for passwords?
  3. How to convert a std::string to const char* or char*?
  4. What is the difference between \"text\" and new String(\"text\")?
  5. How to check if a string \"StartsWith\" another string?
  6. How to check if a String is a numeric type in Java?
  7. What is the difference between String.Empty and \"\" (empty string)?
  8. How to Convert a String into an Integer in JavaScript?
  9. How would you count occurrences of a string within a string?
  10. How do you reverse a string in place in C or C++?
  11. Why does Java\'s hashCode() in String use 31 as a multiplier?
  12. How to split a string with any whitespace chars as delimiters?
  13. How to count the number of occurrences of a char in a String?
  14. Why is this string reversal C code causing a segmentation fault?
  15. In C#, why is String a reference type that behaves like a value type?
  16. What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
  17. How can I remove the trailing spaces from a string?
  18. Why .NET String is immutable? [duplicate]
  19. How to escape braces (curly brackets) in a format string in .NET
  20. Is there a simple script to convert C++ enum to string?
  21. How to nicely format floating numbers to String without unnecessary decimal 0?
  22. How to Convert a string to an enum in C#?
  23. How can we convert String to Int?
  24. How to use GROUP BY to concatenate strings in MySQL?
  25. When should we use intern method of String on String constants?
  26. Can we escape a double quote in a verbatim string literal?
  27. What is the maximum possible length of a .NET string?
  28. Why isn\'t String.Empty a constant?
  29. How can we split a comma delimited string into an array in PHP?
  30. What\'s the best string concatenation method using C#?
  31. How to identify if a string is a number?
  32. Is it possible to modify a string of char in C?
  33. Is there a way to substring a string in Python?
  34. Does Python have a string contains method?
  35. How to count string occurrence in string?
  36. Why doesn\'t calling a Python string method do anything unless you assign its output?
  37. Why is StringTokenizer deprecated?
  38. Is there a way to split strings with String.split() and include the delimiters? [duplicate]
  39. How to check if a string contains another string in Objective-C?
  40. Efficiently replace all accented characters in a string??
  41. What's Hibernate?

String interview questions and answers on advance and basic String with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on String also add your Questions if any you have to ask and for apply in String Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.

Top String interview questions and answers for freshers and experienced

What is String ?

Answer : A string is a finite sequence of symbols, commonly used for text, though sometimes for arbitrary dat

Questions : 1 :: How to generate a random alpha-numeric string?

Here is code for secure, easy, but a little bit more expensive session identifiers. import java.security.SecureRandom;publicfinalclassSessionIdentifierGenerator{privateSecureRandom random...View answers

Questions : 2 :: Why is char[] preferred over String for passwords?

Strings are immutable. That means once you've created the string, if another process can dump memory, there's no way (aside from reflection) you can get rid of the data before GC...View answers

Questions : 3 :: How to convert a std::string to const char* or char*?


If you just want to pass a std::string to a function that needs const char* you can use std::string str;constchar* c = str.c_str(); If you want to get a writable copy, like char *, you can do that...View answers

Questions : 4 :: What is the difference between "text" and new String("text")?

The latter explicitly creates a new and referentially distinct instance of a String object; the former may reuse an instance from the string pool if one is available. You very rarely would ever want...View answers

Questions : 5 :: How to check if a string "StartsWith" another string?

You can add this function to the String prototype: if(typeofString.prototype.startsWith !='function'){// see below for better implementation!String.prototype.startsWith...View answers

Questions : 6 :: How to check if a String is a numeric type in Java?


his is generally done with a simple user-defined function (i.e. Roll-your-own "isNumeric" function). Something like: publicstaticboolean isNumeric(String str){try{double d...View answers

Questions : 7 :: What is the difference between String.Empty and "" (empty string)?

In .Net pre 2.0, "" creates an object while String.Empty creates no object. So it is more efficient to use String.Empty. Source of information .Length == 0 is the fastest option, but .Empty...View answers

Questions : 8 :: How to Convert a String into an Integer in JavaScript?

parseInt or unary plus or even parseFloat with floor or Math.round parseInt: var x = parseInt("1000",10);// you want to use radix// of 10 so you get a decimal number even with a leading...View answers

Questions : 9 :: How would you count occurrences of a string within a string?


If you're using .NET 3.5 you can do this in a one-liner with LINQ: int count = source.Count(f => f =='/'); If you don't want to use LINQ you can do it with: int...View answers

Questions : 10 :: How do you reverse a string in place in C or C++?

#include<stdio.h>void strrev(char*p){char*q = p;while(q &&*q)++q;for(--q; p < q;++p,--q)*p =*p ^*q,*q =*p ^*q,*p =*p ^*q;}int main(int argc,char**argv){do{ printf("%s ",...View answers

Questions : 11 :: Why does Java's hashCode() in String use 31 as a multiplier?

According to Joshua Bloch's Effective Java (a book that can't be recommended enough, and which I bought thanks to continual mentions on stackoverflow): The value 31 was chosen because it is an...View answers

Questions : 12 :: How to split a string with any whitespace chars as delimiters?

Something in the lines of myString.split("s+"); This groups all white spaces as a delimiter. So if I have the string: "Hello[space][tab]World" This should yield the strings "Hello"...View answers

Questions : 13 :: How to count the number of occurrences of a char in a String?

My 'idiomatic one-liner' for this is: int count =StringUtils.countMatches("a.b.c.d","."); Why write it yourself when it's already in commons lang? Spring Framework's oneliner for this...View answers

Questions : 14 :: Why is this string reversal C code causing a segmentation fault?

There's no way to say from just that code. Most likely, you are passing in a pointer that points to invalid memory, non-modifiable memory or some other kind of memory that just can't be processed...View answers

Questions : 15 :: In C#, why is String a reference type that behaves like a value type?

Strings aren't value types since they can be huge, and need to be stored on the heap. Value types are (in all implementations of the CLR as of yet) stored on the stack. Stack allocating strings...View answers

Questions : 16 :: What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

The strcpy() function is designed to work exclusively with strings. It copies each byte of the source string to the destination string and stops when the terminating null character (0) has been...View answers

Questions : 17 :: How can I remove the trailing spaces from a string?

The C language does not provide a standard function that removes trailing spaces from a string. It is easy, however, to build your own function to do just this. The following program uses a custom...View answers

Questions : 18 :: Why .NET String is immutable? [duplicate]

Instances of immutable types are inherently thread-safe, since no thread can modify it, the risk of a thread modifying it in a way that interfers with another is removed (the reference itself is a...View answers

Questions : 19 :: How to escape braces (curly brackets) in a format string in .NET

For you to output foo {1, 2, 3} you have to do something like: string t ="1, 2, 3";string v =String.Format(" foo {{{0}}}", t); To output a { you use {{ and to output a } you use...View answers

Questions : 20 :: Is there a simple script to convert C++ enum to string?

You may want to check out GCCXML. Running GCCXML on your sample code produces: <GCC_XML> <Namespace id="_1" name="::" members="_3 " mangled="_Z2::"/> <Namespace...View answers

Questions : 21 :: How to nicely format floating numbers to String without unnecessary decimal 0?

If the idea is to print integers stored as doubles as if they are integers, and otherwise print the doubles with the minimum necessary precision: publicstaticString fmt(double d){if(d ==(long)...View answers

Questions : 22 :: How to Convert a string to an enum in C#?

StatusEnumMyStatus=(StatusEnum)Enum.Parse(typeof(StatusEnum),"Active",true); I tend to simplify this with: publicstatic T ParseEnum<T>(string value ){return(T)Enum.Parse(typeof( T ),...View answers

Questions : 23 :: How can we convert String to Int?

Try this: int x =Int32.Parse(TextBoxD1.Text); or better yet: int x =0;Int32.TryParse(TextBoxD1.Text,out x); Also, since Int32.TryParse returns a bool you can its return value to make decisions...View answers

Questions : 24 :: How to use GROUP BY to concatenate strings in MySQL?

SELECT id, GROUP_CONCAT(string SEPARATOR ' ')FROMtableGROUPBY...View answers

Questions : 25 :: When should we use intern method of String on String constants?

Java automatically interns String literals. This means that in many cases, the == operator appears to work for Strings in the same way that it does for ints or other primitive values. Since...View answers

Questions : 26 :: Can we escape a double quote in a verbatim string literal?

Use a double quote. ie @"this ""word"" is escaped";

Questions : 27 :: What is the maximum possible length of a .NET string?

The theoretical limit may be 2,147,483,647, but the practical limit is nowhere near that. Since no single object in a .Net program may be over 2GB and the string type uses unicode (2 bytes for each...View answers

Questions : 28 :: Why isn't String.Empty a constant?

The reason that static readonly is used instead of const is due to use with unmanaged code, as indicated by Microsoft here in the Shared Source Common Language Infrastructure 2.0 Release. The file to...View answers

Questions : 29 :: How can we split a comma delimited string into an array in PHP?

$myArray = explode(',', $myString);

Questions : 30 :: What's the best string concatenation method using C#?

The StringBuilder.Append() method is much better than using the + operator. But I've found that, when the concatenations are less than 1000, String.Join() is even more efficient than...View answers

Questions : 31 :: How to identify if a string is a number?

int n;bool isNumeric = int.TryParse("123", out n);

Questions : 32 :: Is it possible to modify a string of char in C?

When you write a "string" in your source code, it gets written directly into the executable because that value needs to be known at compile time (there are tools available to pull software apart...View answers

Questions : 33 :: Is there a way to substring a string in Python?

>>> x = "Hello World!">>> x[2:]'llo World!'>>> x[:2]'He'>>> x[:-2]'Hello Worl'>>> x[-2:]'d!'>>> x[2:-2]'llo...View answers

Questions : 34 :: Does Python have a string contains method?

You can use the in operator: ifnot"blah"in somestring:continue Or more idiomatically: if"blah"notin...View answers

Questions : 35 :: How to count string occurrence in string?

var temp = "This is a string.";// the g in the regular expression says to search the whole string // rather than just find the first occurrencevar count = (temp.match(/is/g) ||...View answers

Questions : 36 :: Why doesn't calling a Python string method do anything unless you assign its output?

This is because strings are immutable in Python. Which means that X.replace("hello","goodbye") returns a copy of X with replacements made. Because of that you need replace this...View answers

Questions : 37 :: Why is StringTokenizer deprecated?

StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split...View answers

Questions : 38 :: Is there a way to split strings with String.split() and include the delimiters? [duplicate]

You can use Lookahead and Lookbehind. Like...View answers

Questions : 39 :: How to check if a string contains another string in Objective-C?

NSString*string =@"hello bla bla";if([string rangeOfString:@"bla"].location ==NSNotFound){NSLog(@"string does not contain bla");}else{NSLog(@"string contains bla!");} The key is noticing...View answers

Questions : 40 :: Efficiently replace all accented characters in a string??

ere is one way to do this: function makeSortString(s){if(!makeSortString.translate_re) makeSortString.translate_re =/[öäüÖÄÜ]/g;var translate...View answers

Questions : 41 :: What's Hibernate?

Hibernate is a popular framework of Java which allows an efficient Object Relational mapping using configuration files in XML format. After java objects mapping to database tables, database is used...View answers
More Question

Ask your interview questions on String

Write Your comment or Questions if you want the answers on String from String Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---