DevTrain Startseite Advanced Developers Conference vom 14.-15. Februar 2011  
  
  
SUCHEN:  
ARTIKEL ONLINE: 525   

Kategorien
.NET
Datenbanken
Web
XML

Allgemein
Camp
Foren
Events
Persönliche Einstellungen
Registrieren
Prämien Shop
Kontakt
Impressum
Über DevTrain

Autoren



 

Forum: .Net Allgemein | Thema: 20 questions on C# | Von: G. Guest ( 01.12.2005 09:22)

20 Questions on C#

Some questions on C#


1) Which one of the following code samples creates a class that is passed by value?
[Serializable]
public class Weather {...}

public class Weather : MarshalByVal {...}

public class Weather : MarshalByValObject {...}

[MarshalByVal]
public class Weather {...}

[CallContext(MarshalType.ByValue)]
public class Weather {...}
----------------------------------------
2) Which one of the following code samples is a representation of how the read/write string property "Name" is implemented as in MSIL?

public string get_Name() {...};
public void set_Name(string value) {...}

public void get_Name(out value) {...};
public void set_Name(string value) {...}

public string GetName() {...};
public void SetName(string value) {...}

public string Name() {...};
public void Name(string value) {...}

-------------------------------------------
3) In the above sample code, what happens if the DoPublish() method raises the event OnPublish and there are NO subscribers to the event?
public class Publisher
{
public event EventHandler OnPublish;

public void DoPublish() {
OnPublish(this, null);
}
}
Answer: An ApplicationException is raised.
---------------------------------------------

4)
A named or positional parameter of an "Attribute" type can be which one of the following

System.Type
System.Sbyte
System.UInt16
System.UInt64
System.Decimal

---------------------------------------------
5)
Which one of the following code samples uses pre-processing directives to prevent a project from compiling when both the Release and Debug symbols are defined?
#if Debug && Release
#error A build can't be both debug and release
#end if

#if Debug && Release
#throw A build can't be both debug and release
#endif

#if Debug & Release
#throw A build can't be both debug and release
#end if

#if Debug && Release
#error A build can't be both debug and release
#endif

#if Debug && Release
#throw A build can't be both debug and release
#end if

--------------------------------
6)
Which one of the following code samples marks the method with the "STAThread" attribute?
class CSharp {
<Attribute:STAThread>
public void Main(string[] args) {;}
}

class CSharp {
[Attribute:STAThread]
public void Main(string[] args) {;}
}

class CSharp {
[Method:STAThread]
public void Main(string[] args) {;}
}

class CSharp {
[STAThread]
public void Main(string[] args) {;}
}

class CSharp {
<STAThread>
public void Main(string[] args) {;}
}

looks like 4th variant?
----------------------------------------

7)
Which one of the following describes the OO concept of Aggregation?

A system of objects that are not related
A system of objects that are built using each other
A system of objects inherited from each other
A system of objects that implement each other
A system of objects that define each other

----------------------------------------------
8)
Which one of the following keywords causes a compile time error if used in a static method?
lock
continue
fixed
this
using


fixed- never met...
lock – blocks the recourse, should work
continue- will work
this – will work
using – actually it’s written in the beginning of the code, before the implementation…so maybe this one?
------------------------------------------------
9)

Which one of the following types of parameters is considered initially unassigned within a function member?
ref
out
in, out
byref
in
------------------------------------------------
10)
Which one of the following code samples implements an indexer?

class CSharp {
public object CSharp[int idx] {
get {...}
set {...}
}
}

class CSharp {
public class Item[int idx] {
get {...}
set {...}
}
}


class CSharp {
public Item[int idx] {
get {...}
set {...}
}
}


class CSharp {
public object Item[int idx] {
get {...}
set {...}
}
}


class CSharp {
public object this[int idx] {
get {...}
set {...}
}
}
--------------------------------------------------------
11)

What interface do you implement in order to provide a user of your class deterministic, destructor-like cleanup?
ITerminate
IAppDomainSetup
IDestructor
ILease
IDisposable

----------------------------------------------------


12)
What implementation of the ternary operator rewrites the above code?
if (a > b)
c = 'a';
else {
if (b == d)
c = 'e';
else
c = 'b';
}

c = (b = d) ? 'e' : ((a > b) ? 'a' : 'b');
c = (b == d) ? 'e' : (a > b) ? 'a' : 'b';
c = (a > b) ? 'a' : (b = d) ? 'e' : 'b';
c = (a > b) ? 'a' : ((b = d) ? 'e' : 'b');
c = (a > b) ? 'a' : (b == d) ? 'e' : 'b';

---------------------------------------

13)
You are building a solution that processes requests from clients. Each request can be a complex process, taking time, so you have decided to implement this using asynchronous (or parallel) processing.
What C# object provided by the .NET framework do you use to provide in-process methods for handling asynchronous processing in the above scenario?

Delegate
Class
Thread
AsyncProcess
Parallel

Is it AsyncProcess...?
-----------------------------------------

14)
What C# keyword class access modifier specifies that the class is concrete and CANNOT be derived from?
sealed
final
internal
notinheritable
abstract

notinheritable ?
-------------------------------------------


16) What symbol do you use to indicate an XML comment on a line?
#comment
//
///
#xml
// <xml>

?? ???????? ??????...?????????? ???????? ????? ??????? ? ?...
Did not get the question. In C#, the comments are: // and in XML file the comments are <!-- ?

-------------------------------

17)
Destructors CANNOT be implemented in which one of the following?
Types that inherit other types
Types that can be inherited
Heap allocated types
Struct types
User-defined reference types


Struct types ????? ?????????
--------------------------------------

18)
Which one of the following operators is overloadable?
**
,
&
?:

[]
-----------------------------------------
19)
Which one of the following is a limitation resulting from an a class that has an indexer property but does NOT implement the IEnumerator interface?

The class cannot implement a GetEnumerator method.
The "foreach" is not supported.
The indexer must return an "object" type.
Neither the "for" nor "foreach" statements is supported.
The indexer can have only one parameter.

--------------------------------------

20)
Given the above code sample, how do you use an instance of the Manager class polymorphically?
public class Employee
{
protected double mySalary;
public double Salary {
get { return mySalary; }
set { mySalary = value; }
}

public virtual double Earnings {
get { return mySalary; }
}
}

public sealed class Manager : Employee
{
private double myBonus;
public double Bonus {
get { return myBonus; }
set { myBonus = value; }
}

public override double Earnings {
get { return mySalary + myBonus; }
}
}

variants:
Manager objManager = new Employee();
Employee objManager = new Employee(new Manager()); - looks like this one
Manager objManager = new Manager();
Employee objManager = new Employee();
Employee objManager = new Manager();

-----------------

21)
When a property is non-virtual and contains only a small amount of code, the execution environment may replace calls to accessors with the actual code of the accessor.
Which one of the following is the term for the process described above?

interning
JIT
inlining
pinning
PreJIT




Betreff Von Datum
Re: 20 questions on C#
i want the answer of these ques?
G. Guest 18.01.2006 10:42
Re: 20 questions on C#
this i a german forum,<br>i have no hope for answeres
Hannes Preishuber 18.01.2006 11:23
Re: 20 questions on C#
http://p2p.wrox.com/topic.asp?TOPIC_ID=37141<br><br>Thumbs up Imar ;-)
G. Guest 18.01.2006 12:36
Re: 20 questions on C#
Would like the answers to the 20 questions.
G. Guest 07.02.2006 21:30

Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!

 Betreff:
 Nachricht: Den Beitrag finden Sie nun unter: http://beta.devtrain.de/foren Die Benutzerdaten und Foreninhalte von beta.devtrain.de und www.devtrain.de sind die selben.
Sie können sich dort sogar per RSS über neue Inhalte informieren lassen.
Bei Problemen bitte direkt Mail an asp [AT] ppedv.de.

 Signatur:

  



Login
Username:


Passwort:






Passwort vergessen?

Building und Connecting Know-how

© Copyright 2003 ppedv AG