Showing posts with label C Sharp Interview Questions. Show all posts
Showing posts with label C Sharp Interview Questions. Show all posts

Sunday, July 13, 2008

C Sharp Interview Questions: Modifiers

Interview Quesions involving class and method modifiers.

1. What are the features of an abstract class?
Answer: It cannot be instantiated.It can contain abstrast methods and accessors.

2. When an non-abstract class derives from an abstract class with abstract methods or accessors what must it do?
Answer: It must provide implementations for all abstract methods and accessors.

3. What is an abstract method?
Answer: Implicitly it is a virtual method.Permitted only in abstract classes.It has no body.

4. Why are abstract methods not permitted in non-abstract classes?
Answer: Abstract methods have no implementation, which would be required in a concrete class.

5. When a field or local variable is marked const what does it change?
Answer: The value cannot change. It can only be initialized at declaration.

6. How is override used?
Answer: It is used to modify a method, property or indexer to change the implementation.

7. When a field is marked readonly what does it change?
Answer: The value can only be set in the constructor during initialization.

8. In terms of runtime and compile time, compare const and readonly.
Answer. const is compile time and readonly is runtime.

9. What is a sealed class?
Answer: The class cannot be derived by another class.

10. How does static change fields and methods?
Answer: They become global and belong to the type instead of the instance.

11. What is a virtual method?Answer: It is a method that implementation can be changed in a derived class by using the override keyword.

12. Why is modifiying a class with both abstract and sealed an error?
Answer: An abstract class cannot be instantiated

Friday, July 11, 2008

C Sharp Interview Questions: Operators

Questions involving Operators.

1. When the division operator "/" is used with two integers what is result?
Answer: An integer division with the remainder discarded ( 16 / 5 is 3).

2. What is the operator "%"?
Answer: It returns the remainder from the division.

3. What are the operators "" and ""? How do the differ?
Answer:
Operator "" is the bitwise-or operator.
It accepts boolean operands and integer operands.
The second parameter is always evaluated.
For integer operatands the individual bit places are or'ed separately.

Operator "" is the condition-or operator.
If the first operand is true the second parameter will not be evaluated.

4. What are the operators "&" and "&&"? How do the differ?
Answer:
Operator "&" is the bitwise-and operator.
It accepts boolean operands and integer operands.
The second parameter is always evaluated.
For integer operands the individual bit places are and'ed separately.

Operator "&&" is the condition-and operator.
If the first operand is false the second parameter will not be evaluated.

5. What are the operators '>>' and '<<'? Which mathematical operations are similiar? Answer: Operator '>>' is the right shift operator (right bit shift). It is similar to dividing by a power of 2.
Operator '<<' is the left shift operator (left bit shift). It is similar to multiplying by a power of 2.

6. What are the operators '?:' and '??' ?
Answer:
Operator '?:' is the conditional operator and is used in a statement in the form:
(conditional expression) ? (expression 1) : (expression 2)
If the (conditional expression) evaluates to true then the result of (expression 1) is returned.
If the (conditional expression) evaluates to false then the result of (expression 2) is returned.
Operator '??' returns the left operand if the left operand is not null otherwise it returns the right operand.

Sunday, July 6, 2008

C Sharp Interview Questions: Access Modifiers

Questions involving C# Access Modifier keywords.

1. Describe how the keyword "internal" affects access.
Answer: can only be accessed from the same assembly

2. Describe how the keyword "private" affects access.
Answer: can only be accessed from same class or structure

3. Describe how the keyword "protected" affects access.
Answer: can only be accessed from the class where it is declared or a derived class

4. Describe how the keyword "public" affects access.
Answer: No Restriction

5. Can multiple access modifiers be used on a member or type.
Answer: Only the combination "protected internal" is allowed

6. What is the default accessibility of an enum?
Answer: public

7. What is the default accessibility of an interface?
Answer: public

8. What is the default accessibility of a class ?
Answer: private

9. What is the default accessibility of an struct?
Answer: private

Saturday, July 5, 2008

Index Of C# Interview Questions

Index Of C# Interview Questions

Actors

Agarwal Corollary

Agarwal's Law

AP Calculus

ASPNET account

backupfile

backupset

Bright Shiny Object

Bug Focus

Build

C#

Calculus

Code Pattern

Cognitive Load

Compact Net Framework

Coroutine

Daisy Chain Bug

Desktop Virtualization

DEV

Dot Net Framework

Dot Net Singularity

DotNet Singularity

Enterprise Agreement

enum

Even More Law

EventHandler

Exception

Exception Handling

Feature Focus

FileSystemWatcher

Firefox

Five Nines

Full Package Retail

Generator

GPS

helpctr.exe

hex literal

Hyper VTM

IEnumerable

IIS

Index

installer

INT

integer literal

Intellisense

Internet Explorer

Interviewing

Join

Linux

Micro Dot Net Framework

Microsoft Application Virtualization

Microsoft Team System

Microsoft Virtual PC

Mono

Moonlight

Moore's Law

msdb

msinfo.exe

msinfo.htm

MsTest

MultiBrain

MultiCore

multiplatform

MultiThread

Net Framework

NETWORK SERVICE

NUnit

Open Business

Open Value

Open Value Subscription

Parse

Permutation

Poisoned Candy

Prod

Production

QA

Refactor

Regex

Regression Bug

Requirements

Select License Agreement

Separation of Concerns

Serial Port

Server Virtualization

ServiceController

ServiceProcess

Silverlight

Snippets

Software Development

Software Development Practices

Source Control

Sprint

Sprint Aircard

SQL Server

Subroutine

System

System Info

System.Exception

Team Server

Team System Build

TfsBuild

Thread

ThreadStart

Three Nines

TryParse

UAT

uint

Unix

Use Case

User Acceptance Testing

VB.net

Version Control

Virtualization

Visual Studio

VJ#

Web Service

Win32

Win64

Windows Server

Windows Terminal Services

Windows XP

yield

Wednesday, July 2, 2008

C Sharp Interview Question: Basic Part 1

Basic Questions.

1. Does C# support multiple inheritance?
No.

2. Can a class implement more than one interface?
Yes

3. Outline three exception handling code blocks"
try{} catch(){}
try{} finally {}
try{} catch() {} finally {}

4. When is the finally block executed?
When there is an error and a catch block is present the catch block executes first.
Following that the finally block is executed.
When there is no error, the finally block executed immediately after the last line in the flow of the try block.

5. What is the most common use of a finally block?
Release resources acquired or used in the try block.

6. Explain immutable in relation to C#.
All primitive types are immutable which means that after the type is constructed (allocated) it's value will not change. Statements that appear to change the value, actually cause the type to be constructed (reallocated) again.

7. For class named BaseClass and a class named DerivedClass, how would you declare DerivedClass to indicate that it directly inherits from base class?
class DerivedClass : BaseClass

8. What is the implicit parameter of set method of a property?
Value

9. What are three types of comments used in C#?
Single line comments '//'
Multiline comments that start with '/*' and ends with '*/'
XML comments '///'

Sunday, June 29, 2008

C Sharp Interview Questions: Keywords

C Sharp Interview Questions: Keywords

1. List several C# keywords.

abstract
as
base
bool
break
byte
case
catch
char
checked
class
const
continue
decimal
default
delegate,
do,
double
else
enum
event
explicit
extern
false
finally
fixed
float
for
foreach
goto
if
implicit
in
int
interface
internal
is
lock
long
namespace
new
null
object
operator
out
override
params
private
protected
public
readonly
ref
return
sbyte
sealed
short
sizeof
stackalloc
static
string
struct
switch
this
throw
true
try
typeof
uint
ulong
unchecked
unsafe
ushort
using
virtual
volatile
void
while

2. List Several C# Contextual Keywords

from
get
group
into
join
let
orderby
partial (as a type)
partial (as a method)
select
set
value
var
where (generic type constraint)
where (query clause)
yield

3. List several C# Value Type keywords.


bool
byte
char
decimal,
enum
int
long
sbyte
short
struct
uint
ulong
ushort

(note string is a built in reference type, your call on grading it)


4. List several C# Reference Type keywords.


class,
delegate,
interface

(object and string are built in reference types)



5. List several C# Access Modifier keywords.

internal
private
protected
public


6. List several C# Modifier keywords (class modifiers, method modifiers...)

abstract
const
event
extern
override
readonly
sealed
static
unsafe
virtual
volatile



7. List several C# keywords involving iteration statements.

do
for
foreach
in
while


8. List several C# keywords involving selection statements.

if
else
switch


9. List several C# keywords involving jump statements.

break
continue
goto
return

10. List several C# keywords involving Exception Handling statements.

throw
try
catch
finally


11. List several C# keywords involving method parameters.

params
ref
out


12. List several C# keywords involving namespaces.

namespace
using


13. List several C# keywords involving operator.

as
checked
is
new
sizeof
typeof
true
false
stackalloc
unchecked


14. List several C# keywords involving conversion operators.

explicit
implicit
operator



15. List several C# keywords involving access (class access).

base
this


16. List several C# default keywords.

true
false
null