de Ica
Facultad Ingeniera de Sistemas
I Prctica Calificada Lenguaje
1.- You are developing a class named ExtensionMethods. You need to ensure that the
ExtensionMethods class implements the IsEmail() method on string objects.
How should you complete the relevant code? (To answer, drag the appropriate code segments to
the correct locations in the answer area. Each code segment may be used once, more than once,
or not at all.)
2.- An application includes a class named Person. The Person class includes a
method named GetData. You need to ensure that the GetData() method can
beused only by the Person class or a class derived from Person class.
Which access modifier should you use for the GetData() method?
Rpta.- Protected The type or member can be accessed only by code in the same class or
structure, or in a
class that is derived from that class.
Universidad Nacional San Luis Gonzaga
de Ica
Facultad Ingeniera de Sistemas
I Prctica Calificada Lenguaje
3.- You are developing an application by using C#. The application includes the following code
segment. (Line numbers are included for reference only.)
The DoWork() method must not throw any exceptions when converting the obj object to the
IDataContainer interface or when accessing the Data property. You need to meet the
requirements. Which code segment should you insert at line 07?
Rpta.- var dataContainer = obj as IDataContainer as return null if can not cast
4.- You are developing an application. The application includes classes named Employee and
Person and an interface named IPerson.
The Employee class must meet the following requirements:
-It must either inherit from the Person class or implement the IPerson interface.
-It must be inheritable by other classes in the application.
You need to ensure that the Employee class meets the requirements.
Which two code segments can you use to achieve thisgoal? (Each correct answer presents a
complete solution. Choose two.)
ByD
Universidad Nacional San Luis Gonzaga
de Ica
Facultad Ingeniera de Sistemas
I Prctica Calificada Lenguaje
5.- You are creating a class named Employee. The class exposes a string property named
EmployeeType.
The following code segment defines the Employee class. (Line numbers are included for
reference only.)
The EmployeeType property value must be accessed only by code within the Employee classor
within a class
derived from the Employee class.
The EmployeeType property value must be modified only by code within the Employee classor
You need to ensure that the implementation of the EmployeeType property meets the
requirements.
Which two actions should you perform?
Replace line 03 with the following code segment: protected string EmployeeType
6.- Dada dos cadenas de caracteres de mismo tamao, calcular la distancia de Hamming entre
ellos (caracteres que son diferentes en misma posicin)
Ejemplo:
Para string1 = "abab" y string2 = "cbad", el resultado debera ser
hammingDistance(string1, string2) = 2.
Only the first and the last characters are different.
Slo el primero y el ltimo carcter son diferentes.
Input/Output
[input] string string1
La primera cadena de caracteres.
Restriccin:
3 string1.length 10.
[input] string string2
La segunda cadena de caracteres.
Restriccin:
3 string2.length 10.
[output] integer
Distancia Hamming entre string1 y string2.
class Program
{
public void Leer()
{
string string1, string2;
do {
Console.WriteLine("Ingrese cadena 1:");
string1 = Console.ReadLine();
} while (string1.Length <= 3 || string1.Length >= 10);
do {
Console.WriteLine("Ingrese cadena 2:");
string2 = Console.ReadLine();
} while (string2.Length != string1.Length);
hammingDistance(string1, string2);
}
Tip 2: Una de las tantas caractersticas fabulosas que tienen los ornitorrincos son los
espolones en los tobillos los cuales liberan veneno.
{
int Num_mamas { get; set; }
void Amamantar();
}
public interface IAnimalVolador : IAnimal
{
void Ascender();
void Volar();
void Descender();
}
public interface IAnimalAcuatico : IAnimal
{
void Nadar();
void Bucear();
}
public interface IAnimalVenenoso
{
void Envenenar();
void ProducirVeneno();
}