GeekInterview.com
Series: Subject: Topic:

C# Interview Questions

Showing Questions 1 - 20 of 460 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

Which of the following statements is not true for interfaces

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) interface definitions does not have implementationb) interfaces must be declared as publicc) interfaces can be instantiatedd) interface does not have constructorsexplanation: interfaces can only be implemented by inheriting and they can not be instantiated

Answered by: TheDentist on: Apr 23rd, 2013

C is the correct answer. Interfaces dont have constructors so they cant be instantiated.

http://msdn.microsoft.com/en-US/library/vstudio/ms173156.aspx

Answered by: michellext on: Sep 13th, 2012

C) Interfaces can be instantiated

Can we write dotnet console program in UNIX

Asked By: narsimhareddygajjela | Asked On: Jul 30th, 2012

Can we write dotnet console program in UNIX ? If yes give one example.

Answered by: TheDentist on: Apr 23rd, 2013

If you write in Java then the application will run in a JRE on UNIX but you have to compile the application on Windows first. Then deploy it to UNIX.

Answered by: vpote on: Sep 2nd, 2012

You can use mono .net for this

How to handle exceptions without using try catch finally

Asked By: Nitesh | Asked On: Sep 27th, 2006

Answered by: vpote on: Apr 15th, 2013

The best way to do this would be doing the same in global.asax application_error method.

Thanks
Vijay

Answered by: iaskalyani45 on: Jan 18th, 2013

By using "if else" conditional statement

The following code fails. Why?

Asked By: Farhan | Asked On: Nov 12th, 2007

Int a = 5; int b = 5; object oa = a; object ob = b; debug.Assert(oa == ob, "oa is not equal ob");

Answered by: iaskalyani45 on: Jan 18th, 2013

nice answer peter

Answered by: PeterVH on: Aug 19th, 2011

The "==" operand on the 2 int's is comparing value types. Here the content is compared. After boxing the value types into objects, i.e. reference types, the "==" operand compares the references (memo...

How can I check whether a dataset is empty or not in c#.Net

Asked By: Ravinder Nain | Asked On: Feb 2nd, 2006

Answered by: Rajavel on: Nov 19th, 2012

Code
  1. if(dataset.Tables.count!=0)
  2. {
  3. do some operation
  4. }
  5. else
  6. {
  7. nothing...
  8. }

Answered by: Anais on: May 31st, 2012

Thank you Seeker911, your answer helped me :)

Which of the following statement is invalid with regards to constructor

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) constructors should have the same name as class nameb) constructors have to be public so that class can be instantiatedc) constructors can not be overloadedexplanation: constructors can be overloaded with different parameters

Answered by: tmounika on: Nov 1st, 2012

all the three statements are true...

Answered by: Viky on: Oct 4th, 2012

The correct answer is B: as constructors need not be public we can have private constructors also for instance a singleton object has a private constructor

If a.Equals(b) is true then a.Gethashcode & b.Gethashcode must always return same hash code

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) trueb) false

Answered by: Alexandre on: Oct 13th, 2012

Not necessarily. Actually GetHashCode() can always return the same value... :-) Say "1". And everything will work well. Just Hashtable with such a key will not be efficient. Keys in the hashtable are ...

Answered by: Deadbeef66 on: Oct 29th, 2011

FALSE

Both Equals() and GetHashCode() can be overridden by the developer for user-defined classes, so there is no guaranteed behavior.

Program on 3d matrix using random function print the o/p in file.

Asked By: k.sampath kumar | Asked On: Jun 1st, 2012

Program on 3d matrix using random function print the o/p in file find the even,odd,prime numbers from above output file. please do needful help thank you

Why strings are immutable?

Asked By: Rohit Sharma | Asked On: Apr 21st, 2006

Answered by: Jeevan on: Apr 20th, 2012

People, please read the question before answering, don't just answer "Why" is the question - not "how".

Answered by: LordAlex on: Nov 6th, 2011

String is an array of bytes.
When are you ave to change it, you have to create the new one; because the string is always considered as a constant.

My switch statement works differently! Why?

Asked By: Interview Candidate | Asked On: Sep 13th, 2004

C# does not support an explicit fall through for case blocks. The following code is not legal and will not compile in c#: switch(x){case 0:// do somethingcase 1:// do something in common with 0default:// do something in common with//0, 1 and everything elsebreak;}to achieve the same effect in c#, the...

Answered by: Sivavt on: Apr 4th, 2012

Folks:

Empty cases allowed to fall through in C#.

Answered by: TheOutlander on: Aug 20th, 2010

Most of the other answers are right, but there is a caveat.

Empty cases are allowed to fall through. However, the last case statement always needs a break - empty or not.

By declaring a base class function as virtual we allow the function to be overridden in subclasses

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) trueb) falseexplanation: if a function is declared virtual it needs to be overridden in subclass

Answered by: Sivavt on: Mar 29th, 2012

It is not mandatory for a derived class to override the virtual base method. Nevertheless, derived class can opt to override the virtual base method to redefine the functionality.

Answered by: Dinesh M Yadav on: Aug 28th, 2011

The answer is A) TRUE. If you declare a virtual method in a class , its not mandatory to override it in the sub class. However, In case of abstract class, the answer would be B) False since if you ...

C# sealed variables

Asked By: aarruunnaa | Asked On: Dec 2nd, 2007

I have taken a windows application and a button control in it.I want to declare a variable as a sealed and use that variable with in same class as we cannot use in other class. Class test { public sealed int x = 5; public void abc() { ...

Answered by: Sivavt on: Mar 29th, 2012

Keyword sealed can be used with class declaration to prevent it from being sub-classed.
Keyword sealed can be used in method declaration to prevent it from being overridden.

Answered by: Rajeeva on: Sep 4th, 2011


To restrict users from inheriting the class by sealing the class using "sealed" keyword i.e. no class can be drieved from a sealed class. both Class and Method can be sealed, in that case Method cannot be overridden.

Exception handling

Asked By: Suganya | Asked On: Aug 20th, 2011

What is the necessary for "throws" and "throw" in exception handling?? even though the exception has been thrown automatically and being handled by try and catch block..

Answered by: Sivavt on: Mar 29th, 2012

no throws in C#.

throw is used to re-throw exceptions

Answered by: Suresh Jayaraman on: Sep 23rd, 2011

if we have different layers like Dataaccess layer,Business layer ,Presentation layer. The error is in DataAccess layer,that error should come to presentation layer and we can show that error in messa...

Following are the collections in c#:

Asked By: Interview Candidate | Asked On: Nov 27th, 2005

Skill/topic: advanceda) structsb) enumc) dictionariesexplanation: ans. B & c. A isn’t a collection .

Star Read Best Answer

Editorial / Best Answer

Answered by: LordAlex

View all answers by LordAlex

Member Since Nov-2011 | Answered On : Nov 5th, 2011

All collections directly or indirectly should implement the ICollection interface or the ICollection(Of T) generic interface. If you check System.Array you will see ICollection interface in there. Correct answer is C, it doesn't matter that there are methods that can provide arrays of Names and Values. Because if you are reasoning like this, it means bject.ToString().ToCharArray() cause all classes are being collections.

Answered by: Sivavt on: Mar 27th, 2012

C. Dictionary

Enum is not a collection but a distinct type like struct

Answered by: LordAlex on: Nov 5th, 2011

All collections directly or indirectly should implement the ICollection interface or the ICollection(Of T) generic interface. If you check System.Array you will see ICollection interface in there. Co...

Object oriented and object based language

Asked By: abuhurera farooqe | Asked On: Aug 2nd, 2008

Explain what are object oriented language and object based language

Star Read Best Answer

Editorial / Best Answer

Answered by: Aarthy_SP

View all answers by Aarthy_SP

Member Since Dec-2008 | Answered On : Dec 10th, 2008

Any langauge based on encapsulation concpet and operations with the objects are called as Object Based language. Exmaple : VB is a Object based and not an Object oriented

Any langauge based on encapsulation concept and operations with the objects and also dealing with the inheritance and polymorphism are called as Object Oriented language. Exmaple : C++,C#

Answered by: Sivavt on: Mar 27th, 2012

Object based languages do not support inheritance & dynamic binding. Example, VB

Answered by: LordAlex on: Nov 5th, 2011

Object Oriented - supports of using the objects.
Object Based Language - all data types are objects, based on single type object primitive.

When do you absolutely have to declare a class as abstract ?

Asked By: Interview Candidate | Asked On: Sep 15th, 2004

(as opposed to free-willed educated choice or decision based on uml diagram)?  when at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

Answered by: Sivavt on: Mar 26th, 2012

If any of the methods do not have implementation.

Answered by: Devender Thadkapalli on: Nov 28th, 2011

When you do not want to create an object of the class and want to provide some abstract implementation

ex: Class HumanBeing. No Point of creating a class human being. You can create Men or Women out of it an create an object of the derived class

In a multilevel hierarchy how are the constructors are called

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) topdownb) bottomupc) none

Answered by: Sivavt on: Mar 26th, 2012

Order of call: From child to parent
Order of execution: From parent to child

Answered by: Philc137 on: Nov 9th, 2011

Bottom up.

A parent class has no reference to the child class, it's the other way around. The code calls the child class, which then calls the parent class, and so on up. Then the constructors are executed top down.

All .Net code have to be cls compliant

Asked By: Interview Candidate | Asked On: Nov 27th, 2005

Skill/topic: intermediatea) trueb) false

Answered by: Sivavt on: Mar 26th, 2012

Not required. If you want your code to be CLS complaint use the annotation CLScompliant(true)

Answered by: Ravi Kumar on: Dec 3rd, 2011

False All .Net code need not be CLS compliant if you are going to write all modules using single .Net language. However, if you are going to use different .Net language for different modules then you...

Operator overloading

Asked By: Sandeep Dhakad | Asked On: Nov 10th, 2011

Why should we have to overload ==(equals) and !=(not equals) operators in same program? If any one is not overloaded it gives error. Same with =?

Answered by: Sivavt on: Mar 26th, 2012

Comparison operators must be overloaded in pair

Answered by: kabilan on: Jan 3rd, 2012

Same class name and different parameters within one class

Late and early binding

Asked By: kapil | Asked On: Nov 12th, 2011

Which one best in late binding and early binding? What is the difference between them ?

Answered by: Sivavt on: Mar 26th, 2012

Early binding Or Compile time Or static binding: Assigning of object to type reference happens at compile time.

Late binding Or Run time Or Dynamic binding: Assigning of object to type reference happens at run time.

Early binding is efficient while late binding provides flexibility to programmers.

Answered by: Devender Thadkapalli on: Nov 28th, 2011

Early binding is best. Because any errors can be resolved at compile time. Late binding is at Run Time

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.