AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
getBytes()
GetByte()
giveByte()
Give Bytes()
getBytes() stores the character in an array of bytes. It uses default character to byte conversions.
What will be the output of the given code snippet?
staticvoid main(String args[])
{
char chars[]={'x', 'y', 'z'};
String s =newString(chars);
Console.WriteLine(s);
}
x
xy
z
xyz
String(chars) is a constructor of class string, it initializes string s with the values stored in character array chars, therefore s contains “xyz”. Output :xyz
Which of these methods can be used to convert all characters in a String into a character array?
CharAt()
getChars()
TocharArray()
All of the mentioned
Answer: Option (C)
Choose the effective stringBuilder method which helps in producing output for the given code?
staticvoid Main(string[] args)
StringBuilder s =new StringBuilder("object");
s./*______*/("Oriented Language");
Console.ReadLine();
Output : objectOriented Language
Insert()
Add()
Append()
Join()
static void Main(string[] args) { StringBuilder s = new StringBuilder(“object”); s.Append(“Oriented Language”); Console.WriteLine(s); Console.ReadLine(); } Output : objectOriented Language
Which of these methods of the class String is used to obtain length of String object?
get()
Sizeof()
lengthof()
length()
Method length() of string class is used to get the length of the object as string.Length and hence invokes the length() method.
How to print \\ on the screen?
Console.WriteLine(“\\”);
Console.WriteLine(“\\\”);
Console.WriteLine(“\\\\”);
Console.WriteLine(“\\\\\\”);
Console.WriteLine(“\\\\”); Output : \\
What will be the output for the given code snippet?
string s =" i love you";
Console.WriteLine(s.IndexOf('l')+" "+ s.lastIndexOf('o')+" "+ s.IndexOf('e'));
3 5 7
4 5 6
3 9 6
2 4 6
indexof(‘l’) and lastIndexof(‘o’) are pre defined functions which are used to get the index of first and last occurrence of the character pointed by l and c respectively in the given array. Output : 3, 9, 6
How is a string typically processed?
On a character by character basis
On a string by string basis
Both a & b
None of the mentioned
Answer: Option (A)
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies