C# - Test Drive...!!

Descripción

A small test drive - to evaluate a few important concepts from C#
Prashant  Singh R
Test por Prashant Singh R , actualizado hace más de 1 año
Prashant  Singh R
Creado por Prashant Singh R hace alrededor de 6 años
211
0

Resumen del Recurso

Pregunta 1

Pregunta
What must be different between two overloads of a method?
Respuesta
  • EITHER the number of parameters OR the return type of each method overload
  • The names of the method overloads
  • EITHER the number of parameters OR the type of at least one parameter
  • EITHER the number of parameters OR the type of at least one parameter OR the return type of each method overload
  • EITHER the names of the method overloads OR their return types

Pregunta 2

Pregunta
Which operator would you use to attach a handler to an event?
Respuesta
  • =
  • =+
  • +=
  • =>
  • ->

Pregunta 3

Pregunta
Which of the following is a syntactically correct way to declare and initialize an array of "int"?
Respuesta
  • var x = new int[]{1, 2, 3};
  • int[] x = int[] {1, 2, 3};
  • int[3] x = new int{1, 2, 3};
  • var x = new {1, 2, 3};

Pregunta 4

Pregunta
Consider this implementation of an enumerator. If this is enumerated, at what point will the message "In finally block!" be written to the console?
Respuesta
  • It won't, the yield return bypasses the finally block.
  • Once, after the first item in the enumeration has been returned.
  • Three times, once after returning each item in the enumeration.
  • Once, after the enumeration is complete.

Pregunta 5

Pregunta
Name an advantage of passing a parameter to a method by reference, compared to passing by value
Respuesta
  • Passing by reference protects the data in the caller from inadvertant changes to the parameter value inside the called method.
  • If the method throws an exception, passing by reference preserves more information in the stack trace.
  • If the parameter is large, passing by reference saves data copying and can therefore be quicker.
  • Passing by reference allows the method to safely execute on multiple threads simultaneously without risk of corrupting the data in the parameter.

Pregunta 6

Pregunta
In the following code, [System.Web.Services.WebMethod] is an example of which C# language feature?
Respuesta
  • Functional Property
  • WebMethod
  • Attribute
  • Method-Setting

Pregunta 7

Pregunta
What is the main problem with the following code?
Respuesta
  • The variable "ex" has been declared twice in the same context.
  • The variable "ex" is not used in the last catch block.
  • Only one "catch" block can be associated with each "try" block.
  • The last "catch" block is unreachable.

Pregunta 8

Pregunta
Write the following LINQ query using method syntax.
Respuesta
  • var shortNames = names.Where(name => name.Length < 4) .OrderBy(name => name);
  • var shortNames = names.Where(name.Length < 4) .OrderBy(x);
  • var shortNames = names.Where(this.Length < 4) .OrderBy(this);
  • var shortNames = names.Where(this.Length < 4) .OrderBy(this) .Select(this);

Pregunta 9

Pregunta
What is the full name of the "type" that is represented by keyword "long"?
Respuesta
  • System.Int64
  • System.Long64
  • System.Int
  • System.Int32
  • System.Long

Pregunta 10

Pregunta
What does the "params" keyword do when used in a method parameter list?
Respuesta
  • Guides the compiler in which overload of a method to choose
  • Allows arguments of any type to be passed to a method
  • Allows individual arguments to be omitted, with default values supplied, when calling the method
  • Allows a variable number of arguments to be used when a method is called

Pregunta 11

Pregunta
What happens when the below code is executed? public interface ICar { public int getspeed(); }
Respuesta
  • Succeed
  • Compile error
  • Warning

Pregunta 12

Pregunta
class Car { public void DescribeCar() { ShowDetails(); } public virtual void ShowDetails() { System.Console.WriteLine("Standard transportation."); } } class ConvertibleCar : Car { public new void ShowDetails() { System.Console.WriteLine("A roof that opens up."); } } class Minivan : Car { public override void ShowDetails() { System.Console.WriteLine("Carries seven people."); } } public static void TestCars1() { Car car1 = new Car(); car1.DescribeCar(); ConvertibleCar car2 = new ConvertibleCar(); car2.DescribeCar(); Minivan car3 = new Minivan(); car3.DescribeCar(); }
Respuesta
  • Standard transportation Standard transportation Standard transportation
  • Standard transportation A roof that opens up. Carries seven people.
  • Standard transportation Standard transportation Carries seven people.

Pregunta 13

Pregunta
On the whole, which types can you inherit from ?
Respuesta
  • Any struct or class that is not marked as sealed
  • Any class that is not marked as sealed
  • Any class
  • Any type except for the C# built-in types (int, bool, string, etc.)

Pregunta 14

Pregunta
Which of these shows the correct way to declare an extension method on "string" called "WordCount()" ?
Respuesta
  • public static int WordCount (string str) : this str { /* ... */ }
  • public static extension int WordCount (string, string str) { /* ... */ }
  • public extension int string.WordCount(this string str) { /* ... */ }
  • public static int WordCount (this string str) { /* ... */ }

Pregunta 15

Pregunta
What is the visibility of the "CurrentSpeed" property in the following code ? public class Automobile { double CurrentSpeed {get; set;} }
Respuesta
  • Protected internal
  • Protected
  • Internal
  • Public
  • Private

Pregunta 16

Pregunta
Consider the following code. Which of the following is true about the inner "userResponse" declaration?
Respuesta
  • It will cause a compiler error because the name conflicts with the first userResponse declaration
  • It will not allocate a new variable, but will instead overwrite the contents of the outer userResponse variable.
  • It will cause a compiler error because you cannot declare local variables inside a foreach loop.
  • It will cause the outer userResponse variable to be hidden within the foreach loop.

Pregunta 17

Pregunta
What does this code illustrate?
Respuesta
  • A generic collection
  • A generic method
  • A generic constraint
  • A generic type

Pregunta 18

Pregunta
How can you "modify" the "Manager" constructor declaration so that it passes its parameter to the "Employee" constructor
Respuesta
  • public Manager(string name) : base(name) { base.ctor(name) /* ... */ }
  • public Manager(string name) : Employee(name) { /* ... */}
  • public Manager(string name) : base(name) { /* ... */}
  • public Manager(string name) { Employee(name) /* ... */ }

Pregunta 19

Pregunta
What will be the execution result of the following code ?
Respuesta
  • "Hello World!" is displayed in the text block on button click
  • "Hello World!" is displayed in the text block on button click, after 1 second.
  • "Hello World!" is never displayed in the text block
  • "Hello World!" is displayed in the text block on button click, after 10 seconds

Pregunta 20

Pregunta
What will be the execution result of this code (in the console) ?
Respuesta
  • Prints values from 1 to 10
  • Prints "10" - ten times
  • Throws a compiler error - as del() is not a method
  • Prints "1" - ten times
  • Throws a compiler error - as C# "List" cannot have methods in it
Mostrar resumen completo Ocultar resumen completo

Similar

Evaluation of Explanations of Schizophrenia
Charlotte97
Orbital Mechanics
Luke Hansford
Software Processes
Nurul Aiman Abdu
Module 1: Introduction to Engineering Materials
Kyan Clay
Mathematics
rhiannonsian
AOCS - Attitude and orbit control systems
Luke Hansford
Ordinary Differential Equations
rhiannonsian
audio electronics
Lillian Mehler
Building Structures
Niat Habtemariam
communication system
Lillian Mehler