Get benefited from interview Q/A and Online Test section. Subscribe to this blog to get updates directly in your mail box.
Best View in Google Crome, Mozilla firefox or IE 7 or above

Sunday, March 6, 2011

C# Online Test Questions and Answers

1. Can an Interface be instantiated directly?
Yes
No
It can be instantiated with static constructor
None of these
 

2. What is the Difference between Convert.ToInt32 and Int.Parse?
Both are Same
Int.Parse Can't Handle Null values , It will throws ArgumentNullException Error.
Convert.ToInt32 Can't Handle Null Values ,it will throws ArgumentNullException error.
Both can Handle Null Values
Both can't Handle Null Values
 

3. C# doesnot support:
inheritance
polymorphism
abstraction
multiple inheritance
C# supports all
 

4. Whice is true about Interface and abstract methods?
We can write only one abstract method inside interface.
No method is abstract inside interface
All the methods inside Interface in an abstract method.
None of the above
 

5. Which keyword is used to achieve shadowing in C#?
Abstract
Sealed
New
Shadow
None of the above
 

6. Which of the following class cannot be inherited?
Sealed
Abstract
Both
None
 

7. In C#, the statement that is used to replace multiple if statements is called?
?: (ternary operator)
The switch case statement
The nestedif statement
The #endif statement
None of these
 

8. Which of these is a valid path declaration?
string strPath="c:\\abc.txt";
string strPath="c:/abc.txt";
string strPath=@"c:\abc.txt";
All of these
None of these
 

9. What is the difference between Convert.ToString(str) and str.ToString() method?
Convert.ToString(str) function handles NULL while str.ToString() does not. It will throw a NULL reference exception.
str.ToString() function handles NULL while Convert.ToString(str) does not. It will throw a NULL reference exception.
Both can handle NULL
None can Handle NULL
 

10. Waht does a strong name contain?
assembly name
assembly version
publiuc key
All the above
None of these
 

Wednesday, January 12, 2011

Find number of words in a text file in C# Dotnet

The below code can be used to count the number of words in a text file.

using System;
using System.IO;

namespace ConsoleApplication1
{
class CountWords
{
public string content { get; set; }


 internal int wordsInFile(string P)
 {
   return File.ReadAllText(P).Split(' ').Length;
 }
}

class Program
{
 static void Main(string[] args)
 {
 CountWords c = new CountWords();
 int numWords = c.wordsInFile(@"C:\test_data.txt");
 Console.WriteLine(numWords);
 Console.ReadLine();
 }
}
}

Text and Speech Project in C# Dotnet

  © Blogger templates Shiny by Ourblogtemplates.com 2008

Back to TOP