Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

sistran.

com

Evaluation test: Visual C# .Net (Junior)

Last name and name:

Date:

1- Analyze what performance problem(s) exist in the following code and indicate a possible solution .

a)

//Return a list with all books from the DB.


private ArrayList GetListOfBooksFromDB();

public void ShowAllBooks()


{
for ( int i=0; i < GetListOfBooksFromDB().Count; i++)
{
Book book = ( Book )GetListOfBooksFromDB()[i];
Console .WriteLine(book.Author + " - " + book.Title);
}
}

b)

public bool IsChile( object [] countries) {


bool IsChile = false ;

for ( int i = 0; i < countries.Length; i++) {


if (( string )countries[i] == "Chile" )
{
IsChile = true ;
}
}
return IsChile;
}

c)

private static IList Test()


{
List < object > numbers = new List < object >();

for ( int i = 0; i < 1000000; i++) {


numbers.Add(i);
}

return numbers;
}
sistran.com

www.sistran.com
2- Code tracking.

a) Indicate that it is printed on screen.

private void ReplaceString()


{
string s = "Take this out" ;
s.Replace( "this" , "that" );

Console .WriteLine(s);
}

b) Indicate why this code may fail and how to solve it.

//Return the surname of the person if exists, else NULL private string GetSurnameFromDB( string idCard);

public string TestWrong( string idCard)


{
string surname = GetSurnameFromDB(idCard);
string description = null ;

if (surname.Length > 0) {
description = surname + " " + idCard;
}
return description;
}

c) Indicate that it is printed on the screen:

public class Figure


{
public virtual void Draw()
{
Console .WriteLine( "I'm a figure." );
}

public class Circle : Figure


{
public override void Draw()
{
Console .WriteLine( "I'm a cirule." );
}
}

static void Main( string [] args)


{
Figure instance = new Circle ();
instance.Draw();
}
sistran.com

d) Indicate that it is printed on the screen:


public class B: A
{
publicB ()
{}
}

public class C:B


{

www.sistran.com
public C()
{}
}

static void Main( string [] args)


{
B b = new B ();
C c = new C ();
if (c is A )
Console .WriteLine ( "True" ) ; else
Console.WriteLine ( "False" ) ;
}

3 – OOP / .NET / ASP .NET

a) Name at least 5 C# data types (primitive or not)

b) In a class you can define 2 constructors with the same type and number of parameters.

A. TRUE
B. Fake

c) If you design a class that needs special initialization tasks, you will have to write a _____________

A. housekeeping routine
B. initializer
C. builder
D. Compiler

d) A method that does not return any value to the program defines the return value type as _______________

A. C# is not allowed
B. void
C. empty
D. sweep

www.sistran.com
SISTRAN
sistran.com

e) Which of the following statements is false?

A. A method is a block of code that performs a specific task.

B. The methods allow programmers to break down large, complex problems into small, manageable
tasks.

C. Methods allow programmers to reuse existing code to perform common tasks

D. Methods can be called, or are invoked, only once in a program.

E. Programmer-defined methods may or may not return a value.

f) The mechanism that consists of isolating an element from its context or from the rest of the elements
that accompany it is called ________

A. Selectivity
B. Polymorphism
C. Abstraction
D. Summary

g) What is an object?

h) Difference between a class and an interface


A- It is not possible to create an instance of a class
8- Unable to instantiate an interface
C- There is no difference

i) What is an abstract class?

www.sistran.com
sistran.com

4- SQL

BOOKS
IdBook NameBook Price Amount AuthorId IdG January
1. ."....... 1
SQL Server 2005 - Home 102.58 5 4
2 Gone With the Wind 97.12 8 2 3
3 Visual Basic .Net 2005 52.00 20 1 4
4 Dracula 204.98 15 NULL 2
5 Rich Father, Poor Father... 100.21 10 3 NULL

GENDERS
IdG January Description

i1 suspense
2 T error
3 Drama
4 Computing

5 Action

a) Perform an SQL query that returns the name of the books that cost more than $30 and have more than
10 books in stock.

b) Indicate what is the result of the following query :

Select *
from books l
inner join Genres g
on l . GenderId = g . GenderID
sistran.com

SISTRAN
to)
Price | Quantity |
IdBook NameBook AuthorId GenderID GenderID Description

11........... SQL Server 2005 - Home 102.58 5 1 4 4 Informatic


2 Gone With the Wind 97.12 8 2 3 3 Drama
3 Visual Basic .Net 2005 52.00 20 1 4 4 Computing
4 Dracula 204.98 15 NULL 2 2 Terror

b)
IdBook NameBook Price Amount AuthorId GenderID GenderID | Description

i1 SQL Server 2005 - Home 102.58 5 1 4 4 Computing


2 Gone With the Wind 97.12 8 2 3 3 Drama
1
3 Visual Basic .Net 2005 52.00 20 4 4 Computing
4 Dracula 204.88 15 NULL 2 2 T error

5 Rich Father, Poor Father 100.21 10 3


NULL NULL NULL

c)
IdBook NameBook Price Amount AuthorId GenderID GenderID Description

i NULL NULL NULL NULL NULL NULL suspense


4 Dracula 204.98 15 NULL 2 2 Terror
3 3
2 Gone With the Wind 97.12 8 2 Drama
1 SQL Server 2005 - Home 102.58 5 1 4 4 Computing
3 Visual Basic .Net 2005 52.00 20 1 4 4 Computing
NULL NULL NULL NULL NULL NULL 5 Action
SISTRAN

You might also like