Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. Select the correct statement about Attributes used in C#.NET?
  1.    The CLR can change the behaviour of the code depending on attributes applied to it
  2.    If a bugFixAttribute is to recieve three paramteres, then the BugFixAttribute class should implement a zero arguement constructor
  3.    To create a custom attribute we need to create a custom attribute structure and derive it from System.Attribute
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> The CLR can change the behaviour of the code depending on attributes applied to it




Question 2. Choose the file mode method which is used to create a new output file with the condition that the file with same name must not exist.
  1.    FileMode.CreateNew
  2.    FileMode.Create
  3.    FileMode.OpenOrCreate
  4.    FileMode.Truncate
 Discuss Question
Answer: Option A. -> FileMode.CreateNew


Creates a new output file. The file must not already be existing.


Question 3. Which property among the following represents the current position of the stream?
  1.    long Length
  2.    long Position
  3.    int Length
  4.    All of the mentioned
 Discuss Question
Answer: Option A. -> long Length


This property contains the length of the stream. This property is read-only.


Question 4. The correct way to apply the custom attribute called Employer which receives two arguements “ name of the employee and employeeid is?
  1.    Custom attribute can be applied to an assembly
  2.    [assembly : Employer(Ankit",employeeid.one)].
  3.    [ Employer(Ankit", employeeid.second)] class employee{}
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned




Question 5. Which method of character stream class returns the numbers of characters successfully read starting at count?
  1.    int Read()
  2.    int Read(char[] buffer, int index, int count)
  3.    int ReadBlock(char[ ] buffer, int index, int count)
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> int Read(char[] buffer, int index, int count)


Attempts to read the count characters into buffer starting at buffer[count], returning the number of characters successfully read.


Question 6. Which method among the following returns the integer if no character is available?
  1.    int peek()
  2.    int read()
  3.    string ReadLine()
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> int peek()


Obtains the next character from the input stream, but does not remove that character. Returns “1 if no character is available.


Question 7. Select the method which returns the number of bytes from the array buffer:
  1.    void WriteByte(byte value)
  2.    int Write(byte[] buffer ,int offset ,int count)
  3.    write()
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> int Write(byte[] buffer ,int offset ,int count)


Writes a subrange of count bytes from the array buffer,beginning at buffer[offset], returning the number of bytes written.


Question 8. Choose the output returned when read() reads the character from the console?
  1.    String
  2.    Char
  3.    Integer
  4.    Boolean
 Discuss Question
Answer: Option C. -> Integer


Read() returns the character read from the console. It returns the result. The character is returned as an int, which should be cast to char.


Question 9. What is the output returned by Console if ReadLine() stores I/O error?
  1.    1
  2.    0
  3.    False
  4.    I/O EXCEPTION ERROR
 Discuss Question
Answer: Option D. -> I/O EXCEPTION ERROR




Question 10. What will be the output of given code snippet?static void Main(string[] args) {     string h = "i lovelife";     string h1 = new string(h.Reverse().ToArray());     Console.WriteLine(h1);     Console.ReadLine(); }
  1.    efil evoli
  2.    lifelove i
  3.    efilevol i
  4.    efil evol i
 Discuss Question
Answer: Option C. -> efilevol i


Reverse() an inbuilt method reverses all the characters singly and hence embed them into the string completely.
Output :efilevol i


Latest Videos

Latest Test Papers