|
|
|
Junior Member
      
участник
Last Login: 29.12.2005 14:29
Сообщ.: 17,
Visits: 188
|
|
Изучал С# по книжкам и там небыло тем раскрывающих ряд вопросов. Если кто может нормально(без измерения длины эго) ответить, то было бы здорово...
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 {
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 {
public void Main(string[] args) {;}
}
Я думаю 3й вариант...
----------------------------------------
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- не знаю такого...
lock - блокировка ресурса типа монитора должно работать нормально
continue- без проблем
this - без проблем
using вообщето ставится в начале кода, до имлементации метода... может быть оно?
------------------------------------------------
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
Думаю 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 ?
-------------------------------------------
15)
Which one of the following is a valid implementation of the entry point "Main" method?
public void Main(string[] args) {...} - не правильно
public static void Main(int[] args) {...} -не правильно
public static int Main(string[] args) {...} - будет работать если написать return 0;
public static string Main() {...}
public void Main() {...} -не првильно
значит получается ответ public static int Main(string[] args) {...} - будет работать если написать return 0; ??
вообще, по умолчанию пишется
static void Main(string[] args)
--------------------------------
16) What symbol do you use to indicate an XML comment on a line?
#comment
//
///
#xml
//
не понятный вопрос...коментарии делаются двумя слешами в С...
-------------------------------
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; }
}
}
варианты:
Manager objManager = new Employee();
Employee objManager = new Employee(new Manager()); - думаю это
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
--------------------
22)
public class CLSCompliant
{
private uint MethodA() {}
private string MethodB() {}
protected long MethodC() {}
protected unsafe string MethodD() {} - looks like this one
protected static long MethodE() {}
}
What method in the sample code above is NOT CLS-Compliant?
|
|
|
|
|
Supreme Being
      
модератор
Last Login: 24.08.2008 22:23
Сообщ.: 1 329,
Visits: 15 054
|
|
| Это не с brainbench.com случаем вопросы? :)
|
|
|
|
|
Supreme Being
модератор
Last Login: 04.05.2008 13:32
Сообщ.: 7 240,
Visits: 65 445
|
|
1) По моему ни один из них т.к. все это классы, а они всегда передаются как ссылка.
Но если исходить их того что откомпилируется только первый пример, то ответ
[Serializable]
public class Weather {...}
2)
public string get_Name() {...};
public void set_Name(string value) {...}
3) Исключение System.NullReferenceException
4) Любой из перечисленных
5)
#if Debug && Release
#error A build can't be both debug and release
#endif
6)
class CSharp
{
[STAThread]
public void Main(string[] args) { ... }
}
7) В моеме понимании это "A system of objects that are built using each other", но я не уверен
8) this
9) out
10)
class CSharp
{
public object this[int idx]
{
get {...}
set {...}
}
}
11) IDisposable
12) c = (a > b) ? 'a' : (b == d) ? 'e' : 'b';
13) Thread
14) sealed
15) public static int Main(string[] args) {...}
16) ///
17) Struct types
18) &
19) The "foreach" is not supported.
20) Employee objManager = new Manager();
21) inlining
22) Ни один из перечисленных т.к. все они не объявлены как public. Если сделать их public, то проблема будет с методом возвращающим uint
|
|
|
|
|
Junior Member
      
участник
Last Login: 29.12.2005 14:29
Сообщ.: 17,
Visits: 188
|
|
bazil спасибо.
2) по второму вопросу не понял что там хотелось. сейчас дошло..
4) тут требуется указать только 1 ответ. Вобщем то я тут вопрос не совсем понял...
5) я так и думал.
6) я так и думал.
16) я не понял вопрос...
коментарии в C будут просто //
а в xml
22) но там такого варианта ответа нет...как же отвечать если попадется такой вопрос?
|
|
|
|
|
Supreme Being
модератор
Last Login: 04.05.2008 13:32
Сообщ.: 7 240,
Visits: 65 445
|
|
Откуда ты вообще эти вопросы взял?
[quote="devdotnet"]4) тут требуется указать только 1 ответ. Вобщем то я тут вопрос не совсем понял...[/quote]
Вопрос некоректно поставлен. На него нельзя выбрать один ответ.
[quote="devdotnet"]6) я так и думал.[/quote]
Да? А кто писал "Я думаю 3й вариант"? :)
Вариант номер 4 правильный.
[quote="devdotnet"]16) я не понял вопрос...
коментарии в C будут просто //
а в xml [/quote]
В С# можно использовать так называемые XML комментарии, которые начинаются с ///.
Подробности читай в документации
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcoriXMLDocumentation.asp?frame=true
[quote="devdotnet"]22) но там такого варианта ответа нет...как же отвечать если попадется такой вопрос?[/quote]
Опять же вопрос некорректный, но если надо обязательно отвечать, то я за вариант private uint MethodA() {}
|
|
|
|
|
Junior Member
      
участник
Last Login: 29.12.2005 14:29
Сообщ.: 17,
Visits: 188
|
|
>Вопрос некоректно поставлен. На него нельзя выбрать один ответ.
такой вопрос на брейнбенче
>Да? А кто писал "Я думаю 3й вариант"? :)
>Вариант номер 4 правильный.
это я посчитал неправильно. считал с конца, думая что там 4 вариантов ответа а не 5
|
|
|
|
|
Supreme Being
модератор
Last Login: 04.05.2008 13:32
Сообщ.: 7 240,
Visits: 65 445
|
|
[quote="devdotnet"]>Вопрос некоректно поставлен. На него нельзя выбрать один ответ.
такой вопрос на брейнбенче[/quote]
Возможно ты не полностью скопировал текст вопроса или не все варианты ответов. Потому что, в текущем редакции на 4-ый вопрос нельзя выбрать один вариант т.к. все они одинаково подходят.
|
|
|
|
|
|
| | |