Velikost string?
2.
Kolik je vysledek?
Kód: Vybrat vše
((24 | 4096) & (~(1 >> 4)))
zhruba:
Kód: Vybrat vše
class A {
virtual void m1() {}
virtual void m2() {}
void m3() {}
}
class B : A {
virtual void m1() {}
override void m2() {}
void m3() {}
}
Kód: Vybrat vše
A b = new B();
b.m1();
b.m2();
b.m3();
(zhruba) Co udela tohle?
Kód: Vybrat vše
struct S {
public int x;
public int y;
public S(int x, int y) {
this.x = x;
this.y = y;
}
public void Print() {
Console.WriteLine("{0},{1} ",x++,y++);
}
}
class Program
{
static void Main(string[] args)
{
S s;
s.x = 1;
s.y = 2;
s.Print();
s.Print();
}
}
Da se napsat takovyto kod?
Kód: Vybrat vše
interface I<T> {
T m();
}
class x : I<int>, I<System.Int32> {
....
}
6.
Kód: Vybrat vše
interface I1 {}
interface I2 {}
class A<T> : I1 {}
class B<T> : A<T>, I2 {}
A<int> a1 = new B<int>();
A<B<int>> a2 = new B<B<int>>();
Kód: Vybrat vše
a1 as I1 == null
a1 as I2 == null
a2 is A<B<int>>
a2 is B<A<int>>
a1.GetType() == typeof(A<int>)
a1.GetType() == typeof(B<int>)
moznosti:
copy constructor
protected method
extension method
vlastnost (property)
verejna datova polozka (public field)
implementace metod jineho interfacu I2
8. Co plati o uzivatelem vytvorenych tridach?
Muzou mit 0 predku
Muzou mit libovolnou tridu jako predka
Muzou mit libovolnou strukturu jako predka
Mohou implementovat max 1 interface
Mohou se ukladat na zasobniku
Mohou se ukladat na halde
implicitni viditelnost tridy je internal
implicitni viditelnost jejich clenu je internal
Odpovedi:
1. zalezi na platforme
2. 4120
3. A.m1, B.m2, A.m3
4. 1,2 2,3
5. Nejde, protoze int je jen zkratka za System.Int32 (je to stejny typ), prekladac testuje duplicity.
6. false, false, true, false, false, true
7. d,f
8. ne, ne(sealed), ne, ne, ne, ano, ano, ne