Você está na página 1de 5

1. What is a namespace?

Namespace este folosit pentru a organiza elementele dintr-o aplicaie,


coninnd obiecte ce au legtur ntre ele.

2. Is C# case sensitive?
Da.
3. How does a multiline comment look like?
/* comment 1
Comment 2
*/
4. Give 5 example of reserved keywords.
Using, if, while, for, object
5. Identify the mistakes in the following code:
void class Shape
{
public int Lines{get;set;}
void Name{get;set;}

public private TestNumber(number){


return number;
}

Clasele nu au voie sa returneze ceva, doar metodele au retur.


Proprietatile nu pot avea void ca tip.
Test number are doi modificatori de acces( o metoda poate avea doar un
modificator de acces), si nu are specificat ce returneaza(ar trebui sa returneze
int). Parametrul functiei este definit gresit intrucat are nevoie de un tip(int).
6. What is the difference between value type and reference type?
Cand o instanta a value type este create, in memorie este alocat un singur
spatiu pentru a stoca valoarea. Programul la rulare lucreaza direct cu datele
stocate in memorie. In cazul tipului referinta, un obiect este creat in memorie,
apoi este manipulat printr-o referinta separata. Ca un fel de pointer.
Cand copiem un tip valoare cream o copie independenta a originalului, insa,
in cazul tipului referinta am realizat o copie a referintei, care trimite spre
acelasi obiect.
static void Main(string[] args)
{
int i = 75;
float f = 53.005f;
double d = 2345.7652;
bool b = true;
Console.WriteLine(i.ToString());
Console.WriteLine((int)f);
Console.WriteLine((d / 10).ToString());
Console.WriteLine(b);
Console.ReadKey();
}

7. What would be
the output of
the following
code?

75
53
234.57652
True

8. What does the following escape sequences do?


a. \\ - Backslash
b. \ - O ghilimea dubla
c. \n Linie noua
d. \t Tab orizontal
9. What is the difference between private and protected access specifiers?
Elementele marcate cu privat pot fi accesate doar in aceeasi clasa sau structura.
Elementele marcate cu protected pot fi accesate doar in aceeasi clasa sau
structura, sau intr-o clasa derivata din clasa originala.
10.Write a recursive method that determines if a given number is power of 2.
static bool power(int n, int i)
{
while (n > i)
{
return power(n, i * 2);
}
if (n == i)
{
return true;
}
return false;

Metoda se apeleaza: bool isPower = power(n,1);


11.Rewrite the function in point 10 using only the return statement.
bool power(int n)

return (n == 2) ? true : (n % 2 == 1 ? false : power(n / 2));

Se apeleaza folosind power(2).


12.What is the output of the following code?
static void Main(string[] args)
{
Console.WriteLine(default(Guid));
}

00000000-00000000-0000000000000000
Valoarea default
a Globally Unique Identifier.
13.What does this mean: var b = a ?? c;
B ia valoarea A, daca a nu este null, in caz contrar ia valoarea lui C.
14.Write a class that performs mathematical operations with big numbers. Do
operations on strings. Do not use System.Numbers.BigNumber. The class
will have the following methods:
a. string Add(string a, string b);
b. string Substract(string a, string b)
c. string Multiply(string a, string b)
d. string Divide(string a, string b)
15.Write a function that returns a two-dimensional array where each cell is an
integer representing the product between its position on row and column.
For example: a[2, 3] = 6
16.Write a class that receives in its constructor an array of string objects.
Write the following functions for this class:
a. A function that returns the concatenated strings as one string.
b. A function that returns the total number of characters in all strings.
c. A function that returns the total distinct characters in all strings.
d. A function that, given a string S, returns that string replacing the
letters a, A, b, B with the letter X.
17.What is an enum?
Enum este un cuvant cheie folosit pentru a declara o enumerare. Consta
intr-o lista de constante;
18.What is the purpose of a static function?
Poate fi accesata chiar daca nu a fost creata o instanta a clasei. Functia
este apelata cu numele clasei, nu cu o instanta a sa. Exista o singura copie
a functiei.
19.What is an interface?

Interfata contine doar semnaturile membrilor. Clasa sau structul care


implementeaza interfata, trebuie sa implementeze membrii interfetei, care
sunt specificati in definitia ei.

20.Give an example of polymorphism in code.


Function Overloading mai multe definitii pentru aceeasi functie
Dynamic Polymorphism overriding a method.
21.Write a class with the following methods:
a. A function that returns all .txt file names from the computers desktop.
b. A function that, given a filename and path, copies the content of the
file to C:\
c. A function that, given a directory path, return the biggest file in that
directory and its subdirectories.
22.What is the difference between List<T> and Dictionary<T, T>?
Listele sunt folosite pentru a stoca mai multe obiecte de acelasi gen.
Dictionarele sunt folosite pentru a lega un obiect sau o valoare cu o un alt
obiect sau valoare.
Itemii din liste sunt accesati prin indecsi pe cand, in cazul dictionarelor se
foloseste o pereche (cheie, valoare), fiecare cheie avand o valoare ca si
corespondent.
23.Write a program that manages a library. Implement the following features:
a. Write the number of books currently in the inventory.
b. Write on the screen all the authors for the books in the library order by
LastName and FirstName followed by number of distinct books written
by the author. For example:
i. Author 1 2 books
ii. Author 2 45 books
iii. Author 3 1 book
c. Write on the screen all the books that start with the letter H.
24.What is the difference between a Hashtable and a Dictionary?
Hashtable are thread safety. Suporta mai multe threaduri de citire cu un
thread de scriere. In cazul dictionarului trebuie implementata o sincronizare
proprie.
Cand se folosesc indecsii pentru a extrage o valoare din hashtable hashtable
va returna null in cazul unei valorii inexistente. Dictionarul va arunca o
eroare, daca vei incerca sa accesezi un item folosind un index ce nu exista in
dictionar.
25.Write a program that can be used to hold all the words and their definitions
in all languages. Implement the following 2 methods:
a. void AddWord(string language, string word, string definition)
b. string GetWordDefinition(string language, string word)
26.Write a program that outputs on the console the current time in the format
HH:mm once every 2 seconds.

27.Write a program that saves the content of the webpage https://www.hrp.ro/


to a local file.
28.Write a console program that, once executed, outputs the number of
currently running processes on this computer and the one which has the
most memory consumption.
29.Write a console program that listens for user input and does the following:
a. When the users pressed 1 Notepad is opened.
b. When the user pressed 2 the previous instance of Notepad is closed.
c. When user pressed 3 all opened instances of Notepad are closed.
30.Write a program that will generate a System.OutOfMemoryException
exception in under 5 seconds.

Você também pode gostar

  • Just Be Yourself
    Just Be Yourself
    Documento7 páginas
    Just Be Yourself
    George Buzoianu
    Ainda não há avaliações
  • Legea 119
    Legea 119
    Documento18 páginas
    Legea 119
    ISOLDAcleo
    Ainda não há avaliações
  • Orar 4 A
    Orar 4 A
    Documento2 páginas
    Orar 4 A
    George Buzoianu
    Ainda não há avaliações
  • Futilitate
    Futilitate
    Documento1 página
    Futilitate
    George Buzoianu
    Ainda não há avaliações
  • FD
    FD
    Documento1 página
    FD
    George Buzoianu
    Ainda não há avaliações
  • Autumn
    Autumn
    Documento1 página
    Autumn
    George Buzoianu
    Ainda não há avaliações
  • Aplicatii
    Aplicatii
    Documento2 páginas
    Aplicatii
    George Buzoianu
    Ainda não há avaliações
  • Exercitii C# 2
    Exercitii C# 2
    Documento1 página
    Exercitii C# 2
    George Buzoianu
    Ainda não há avaliações
  • Wordsfsdf
    Wordsfsdf
    Documento1 página
    Wordsfsdf
    George Buzoianu
    Ainda não há avaliações
  • !!
    !!
    Documento1 página
    !!
    George Buzoianu
    Ainda não há avaliações
  • O Alta Viata
    O Alta Viata
    Documento1 página
    O Alta Viata
    George Buzoianu
    Ainda não há avaliações
  • Tell About Me
    Tell About Me
    Documento1 página
    Tell About Me
    George Buzoianu
    Ainda não há avaliações
  • My Quotes
    My Quotes
    Documento2 páginas
    My Quotes
    George Buzoianu
    Ainda não há avaliações