Вы находитесь на странице: 1из 4

.NET Questions for interview 1. What will be the output of the following code ---------------------------------------------( 2 ) int a = 5; int b = 5 / 2; Console.

WriteLine(b has value + b.ToString()); 2. Find bugs in the following code ------------------------------------------------------------------- (5) int condition = 1; while(condition) { Console.WriteLine(the value of b and c are :,b,c); int b = 0; int c = 5; int temp = b; c = b; b = temp; Console.WriteLine(after swapping b and c are:,b,c); try { Console.WriteLine(b divided by C is + (b/c).ToString()); }catch(Expeption Ex) { Console.WriteLine(there was something wrong with the operation); throw ex; }finally { continue; } break; }

3. True of False : A structured programming langauge is better than just OOP language--------(1)

4. Write a class with the following specification-------------------------------------------------------(15) 1. class name : Aeroplane -------------------------------------------------------------------(0.5) 2. class access modifier : public ------------------------------------------------------------(0.5) 3. public properties ---------------------------------------------------------------------------(1) 1. ModelNumber string 2. PlanNumber string 3. BarCode int 4. PassengerCapacity int 5. TotalFuel 4. private fields -------------------------------------------------------------------------------(1) 1. _fuelRemaining float 2. _fuelConsumed 3. _destination string 4. _currentPosition string 5. static fields ---------------------------------------------------------------------------------(2) 1. TotalPlanesCurrentlyInFlight : int 2. TotalPlanesOnGround : int 6. Constructors -------------------------------------------------------------------------------(5) 1. A constructor that can be used to set the values of _fuelRemaining, _destination, _currentPosition and ModelNumber all other private members must be set to default ( empty for string and 0 for numeric) 2. A default constructor that doesn't take in any parameter but initializes the private members to default values ( empty for string and 0 for numeric) 7. Public Methods ----------------------------------------------------------------------------(5) 1. GetFuelRemaining : returns TotalFuel FuelConsumed. If this value is negative return 0 . 2. SetFuelConsumed : set fuel consumed to the value provided or equal to TotalFuel if greater than TotalFuel. 5. Create and array of 10 Aeroplane objects where aeroplane is a class as defined in question number 4. ------------------------------------------------------------------------------------------------(3) 6. Create a child class of the class in Question number 4, -------------------------------------------(11) 1. Change the GetFuelRemaining so that it can be overridden and override it in the child class 2. Change the SetFuelConsumed so that it cannot it cannot be overridden but can be used in child class 3. Add a private method in child class which can be used to take care of all the initialization when called from constructor. 7. What will be the output when the main method is run ------------------------------------------(2) public void main() { int a = 5;

int b = 10; Swap(a,b); Console.WriteLine( a = + a.ToString() + b= + b.ToString()); } public void Swap(int a, int b) { a = a + b; b = a b; a = a b; } 8. Which is true : C# (.net) 'int' and 'int[]' are --------------------------------------------------------(3) 1. Both are value types and both are objects 2. 'int' is a 'class' and 'int[]' is a 'value type' and both are objects 3. 'int' is a 'value type' and 'int[]' is a class but only int[] is an object 4. 'int' is a 'value type' and 'int[]' is a class and both are objects 9. Look at the following code snippet ----------------------------------------------------------------(2) Button B = new Button(); B.Click += new EventHandler(ButtonClicked_1); B.Click += new EventHandler(ButtonClicked_2); What will happen when the B is actually clicked 1. 2. 3. 4. ButtonClicked_1 will only be called ButtonClicked_2 will only be called ButtonClicked_2 will be called after ButtonClicked_1 We cannot assign to event handlers so it will produce an error

10. True or False : Java and .NET both must have a runtime installed to run thus CLR is equivalent to JRE in java. ------------------------------------------------------------------------------------------(1) 11. True or False: A DLL designed for ASP.NET can be added as Reference in .NET desktop application ------------------------------------------------------------------------------------------------(1) 12. True or False: A DLL created in VB.net can be used in a C# .NET project ----------------------(1) 13. You have an array of integers and its length is 100. Write code to convert that one dimensional array in two dimensional array of width 10 and height 10. ----------- -------------------------- (15) 14. True or False : We can use pointers in C# ------------------------------------------------------------(3) 15. True or False : We can make DateTime null ---------------------------------------------------------(2) 16. About Interface and Abstract Classes, which of the following are true --------------------------(10) 1. Both are same 2. Interfaces are equivalent to Abstract Classes with members declared as virtual 3. We can implement multiple interfaces 4. We can inherit multiple abstract classes 5. Interface enforce contractual binding.

Вам также может понравиться