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
Select the objects of the class TextWriter which is/are used to perform the write operations to the console?
Write()
WriteLine()
WriteError()
All of the mentioned
TextWriter is a class with objects as write() and writeline().
Which of the following statement is correct?
reverse() method reverses all characters.
reverseall() method reverses all characters.
replace() method replaces all instances of a character with new character.
replace() method replaces first occurrence of a character in invoking string with another character
reverse() and replace() are by definition.
Select the method used to write single byte to a file?
Wrteline()
WriteByte()
To write a byte to a file, the WriteByte( ) method is used. Its simplest form is shown here: void WriteByte(byte value)
Choose the correct statement about the WriteLine()?
Can display one or more value to the screen
Adds a newline character at the end of the each new output
Allows to output data in as many different formats
None of the mentioned
By the definition of writeline().
What would be the output of given code snippet?
staticvoid Main(string[] args)
{
String a ="i love iostream";
Console.WriteLine(a.IndexOf('i')+" "+ a.IndexOf('e')+" "+ a.LastIndexOf('i')+" "+ a.LastIndexOf('e'));
Console.ReadLine();
}
0 6 7 8
0 5 7 9
5 9 0 7
0 5 7 12
indexof(‘i’) and lastIndexof(‘i’) are pre defined functions which are used to get the index of first and last occurrence of the character pointed by i in the given array. Output : 0 5 7 12
Select the namespace/namespaces which consists of methods like Length(), Indexer(), Append() for manipulating the strings.
System.Class
System.Array
System.Text
The system.text namespace contains the Stringbuilder class and hence must include using system.text for manipulating the mutable strings.
What will be the output of given code snippet?
string h ="i lovelife";
string h1 =newstring(h.Reverse().ToArray());
Console.WriteLine(h1);
efil evoli
lifelove i
efilevol i
efil evol i
Reverse() an inbuilt method reverses all the characters singly and hence embed them into the string completely. Output :efilevol i
StringBuilder sb =new StringBuilder("hello world");
sb.Insert(6, "good");
Console.WriteLine(sb);
hello 6world
hello good world
hello goodworld
The insert() method inserts one string into another. It is overloaded to accept values of all simple types, plus String and Objects. String is inserted into invoking object at specified position. “Good ” is inserted in “Hello World” index 6 giving “Hello Good World”.
Which of these classes is used to create an object whose character sequence is mutable?
String()
StringBuilder()
Both of the mentioned
Mutable strings are dynamic strings. They can grow dynamically as characters are added to them. stringbuilder class supports those methods that are useful for manipulating dynamic strings.
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